From 4b2496b2792fd92772e0d8cdb50cd8f4f5cb9b7b Mon Sep 17 00:00:00 2001 From: rustdev Date: Thu, 4 Apr 2024 20:04:23 +0100 Subject: [PATCH 1/2] update datatype for min cosmos fee in tx to sdk.Coin --- .../ibctransfermiddleware/v1beta1/tx.proto | 10 +- x/ibctransfermiddleware/client/cli/tx.go | 24 ++- x/ibctransfermiddleware/keeper/msg_server.go | 15 +- x/ibctransfermiddleware/types/msg.go | 6 +- x/ibctransfermiddleware/types/tx.pb.go | 181 ++++++++---------- 5 files changed, 95 insertions(+), 141 deletions(-) diff --git a/proto/composable/ibctransfermiddleware/v1beta1/tx.proto b/proto/composable/ibctransfermiddleware/v1beta1/tx.proto index a2550680..91cd2c35 100644 --- a/proto/composable/ibctransfermiddleware/v1beta1/tx.proto +++ b/proto/composable/ibctransfermiddleware/v1beta1/tx.proto @@ -6,6 +6,7 @@ import "amino/amino.proto"; import "gogoproto/gogo.proto"; import "cosmos_proto/cosmos.proto"; import "composable/ibctransfermiddleware/v1beta1/ibctransfermiddleware.proto"; +import "cosmos/base/v1beta1/coin.proto"; option go_package = "x/ibctransfermiddleware/types"; @@ -103,14 +104,9 @@ message MsgAddAllowedIbcToken { (gogoproto.customname) = "ChannelID" ]; - string denom = 3 [ - (gogoproto.moretags) = "yaml:\"channel_id\"", - (gogoproto.customname) = "Denom" - ]; - - int64 amount = 4; + cosmos.base.v1beta1.Coin min_fee = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; - int64 percentage = 5; + int64 percentage = 4; } message MsgAddAllowedIbcTokenResponse {} diff --git a/x/ibctransfermiddleware/client/cli/tx.go b/x/ibctransfermiddleware/client/cli/tx.go index 1d212ff8..c8b86a01 100644 --- a/x/ibctransfermiddleware/client/cli/tx.go +++ b/x/ibctransfermiddleware/client/cli/tx.go @@ -10,6 +10,8 @@ import ( "github.com/cosmos/cosmos-sdk/version" "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types" "github.com/spf13/cobra" + + sdk "github.com/cosmos/cosmos-sdk/types" ) // GetTxCmd returns the tx commands for staking middleware module. @@ -75,28 +77,25 @@ func AddIBCFeeConfig() *cobra.Command { func AddAllowedIbcToken() *cobra.Command { cmd := &cobra.Command{ - Use: "add-allowed-ibc-token [channel] [denom] [amount] [percentage]", + Use: "add-allowed-ibc-token [channel] [percentage] [coin]", Short: "add allowed ibc token", - Args: cobra.MatchAll(cobra.ExactArgs(4), cobra.OnlyValidArgs), - Example: fmt.Sprintf("%s tx ibctransfermiddleware add-allowed-ibc-token [channel] [denom] [amount] [percentage] (percentage '5' means 1/5 of amount will be taken as fee) ", version.AppName), + Args: cobra.MatchAll(cobra.ExactArgs(3), cobra.OnlyValidArgs), + Example: fmt.Sprintf("%s tx ibctransfermiddleware add-allowed-ibc-token [channel] [percentage] [coin] (percentage '5' means 1/5 of amount will be taken as fee) ", version.AppName), RunE: func(cmd *cobra.Command, args []string) error { channel := args[0] - denom := args[1] - amount := args[2] - percentage := args[3] - - clientCtx, err := client.GetClientTxContext(cmd) + percentage := args[1] + coin, err := sdk.ParseCoinNormalized(args[2]) if err != nil { return err } - fromAddress := clientCtx.GetFromAddress().String() - - amountInt, err := strconv.ParseInt(amount, 10, 64) + clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err } + fromAddress := clientCtx.GetFromAddress().String() + percentageInt, errPercentage := strconv.ParseInt(percentage, 10, 64) if errPercentage != nil { return errPercentage @@ -105,8 +104,7 @@ func AddAllowedIbcToken() *cobra.Command { msg := types.NewMsgAddAllowedIbcToken( fromAddress, channel, - denom, - amountInt, + coin, percentageInt, ) diff --git a/x/ibctransfermiddleware/keeper/msg_server.go b/x/ibctransfermiddleware/keeper/msg_server.go index f3fc4daa..dbe7b0f7 100644 --- a/x/ibctransfermiddleware/keeper/msg_server.go +++ b/x/ibctransfermiddleware/keeper/msg_server.go @@ -101,21 +101,14 @@ func (ms msgServer) AddAllowedIbcToken(goCtx context.Context, req *types.MsgAddA params := ms.Keeper.GetParams(ctx) channelFee := findChannelParams(params.ChannelFees, req.ChannelID) if channelFee != nil { - coin := findCoinByDenom(channelFee.AllowedTokens, req.Denom) + coin := findCoinByDenom(channelFee.AllowedTokens, req.MinFee.Denom) if coin != nil { - coin_c := sdk.Coin{ - Denom: req.Denom, - Amount: sdk.NewInt(req.Amount), - } - coin.MinFee = coin_c + coin.MinFee = req.MinFee coin.Percentage = req.Percentage } else { - coin_c := sdk.Coin{ - Denom: req.Denom, - Amount: sdk.NewInt(req.Amount), - } + coin := &types.CoinItem{ - MinFee: coin_c, + MinFee: req.MinFee, Percentage: req.Percentage, } channelFee.AllowedTokens = append(channelFee.AllowedTokens, coin) diff --git a/x/ibctransfermiddleware/types/msg.go b/x/ibctransfermiddleware/types/msg.go index fbb9d459..e07e3ca1 100644 --- a/x/ibctransfermiddleware/types/msg.go +++ b/x/ibctransfermiddleware/types/msg.go @@ -98,15 +98,13 @@ var _ sdk.Msg = &MsgAddAllowedIbcToken{} func NewMsgAddAllowedIbcToken( authority string, channelID string, - denom string, - amount int64, + minFee sdk.Coin, percentage int64, ) *MsgAddAllowedIbcToken { return &MsgAddAllowedIbcToken{ Authority: authority, ChannelID: channelID, - Denom: denom, - Amount: amount, + MinFee: minFee, Percentage: percentage, } } diff --git a/x/ibctransfermiddleware/types/tx.pb.go b/x/ibctransfermiddleware/types/tx.pb.go index feeca5b0..d12a72ed 100644 --- a/x/ibctransfermiddleware/types/tx.pb.go +++ b/x/ibctransfermiddleware/types/tx.pb.go @@ -7,6 +7,7 @@ import ( context "context" fmt "fmt" _ "github.com/cosmos/cosmos-proto" + types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/msgservice" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" @@ -334,11 +335,10 @@ var xxx_messageInfo_MsgRemoveIBCFeeConfigResponse proto.InternalMessageInfo type MsgAddAllowedIbcToken struct { // authority is the address that controls the module (defaults to x/gov unless // overwritten). - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty" yaml:"authority"` - ChannelID string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` - Denom string `protobuf:"bytes,3,opt,name=denom,proto3" json:"denom,omitempty" yaml:"channel_id"` - Amount int64 `protobuf:"varint,4,opt,name=amount,proto3" json:"amount,omitempty"` - Percentage int64 `protobuf:"varint,5,opt,name=percentage,proto3" json:"percentage,omitempty"` + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty" yaml:"authority"` + ChannelID string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` + MinFee types.Coin `protobuf:"bytes,3,opt,name=min_fee,json=minFee,proto3" json:"min_fee"` + Percentage int64 `protobuf:"varint,4,opt,name=percentage,proto3" json:"percentage,omitempty"` } func (m *MsgAddAllowedIbcToken) Reset() { *m = MsgAddAllowedIbcToken{} } @@ -388,18 +388,11 @@ func (m *MsgAddAllowedIbcToken) GetChannelID() string { return "" } -func (m *MsgAddAllowedIbcToken) GetDenom() string { +func (m *MsgAddAllowedIbcToken) GetMinFee() types.Coin { if m != nil { - return m.Denom - } - return "" -} - -func (m *MsgAddAllowedIbcToken) GetAmount() int64 { - if m != nil { - return m.Amount + return m.MinFee } - return 0 + return types.Coin{} } func (m *MsgAddAllowedIbcToken) GetPercentage() int64 { @@ -561,53 +554,54 @@ func init() { } var fileDescriptor_bf5c053de6965bca = []byte{ - // 729 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0xb1, 0x6f, 0xd3, 0x4a, - 0x18, 0x8f, 0xdb, 0x97, 0x48, 0xb9, 0x4a, 0xef, 0xbd, 0xfa, 0xb5, 0x7d, 0xc1, 0xa2, 0x76, 0xe4, - 0x29, 0xaa, 0x44, 0x4c, 0x02, 0xa2, 0x52, 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6, 0xf8, 0x41, 0x00, 0xcb, - 0xc9, 0x96, 0xa9, 0x5f, 0xdd, 0xea, 0xa6, 0xd9, 0xae, 0xb4, 0x75, 0x0d, 0x8c, 0x29, 0x56, 0x26, - 0xbe, 0x17, 0xc0, 0x3f, 0xe3, 0x3e, 0xf6, 0x70, 0x26, 0xfc, 0xb1, 0x6a, 0xa9, 0x76, 0x93, 0xea, - 0x98, 0xd7, 0xa1, 0x00, 0xc4, 0x04, 0xdb, 0xd8, 0x9c, 0x09, 0x7c, 0x12, 0x40, 0x7a, 0x72, 0x43, - 0x80, 0x4b, 0x04, 0x13, 0x5c, 0x61, 0x73, 0xd6, 0xee, 0xc7, 0x00, 0x66, 0x24, 0x38, 0xfd, 0x4d, - 0x0c, 0xff, 0x83, 0xc9, 0xaf, 0xa1, 0x7e, 0x0d, 0x0d, 0xc6, 0x69, 0x6e, 0xdd, 0x1c, 0x63, 0xc8, - 0x54, 0x4a, 0xbf, 0x1c, 0x1c, 0xe4, 0xfa, 0xfa, 0x71, 0x5f, 0x16, 0x4e, 0xfa, 0xb2, 0xf0, 0xbd, - 0x2f, 0x0b, 0xef, 0x4e, 0xe5, 0xd4, 0xc9, 0xa9, 0x9c, 0xfa, 0x76, 0x2a, 0xa7, 0x9e, 0xaf, 0x4e, - 0x3b, 0xbc, 0x59, 0xd7, 0x47, 0xb4, 0x95, 0x09, 0x3f, 0x55, 0xee, 0xfd, 0x0c, 0x00, 0x00, 0xff, - 0xff, 0x87, 0x62, 0x58, 0x5e, 0xac, 0x09, 0x00, 0x00, + // 752 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0xbf, 0x6f, 0xd3, 0x40, + 0x14, 0x8e, 0x5b, 0x5a, 0x94, 0xab, 0x04, 0xd4, 0xb4, 0x90, 0x46, 0xd4, 0x89, 0x3c, 0x45, 0x95, + 0x48, 0x48, 0x40, 0x54, 0xaa, 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 0x4e, 0x4c, 0x95, 0xba, 0x81, 0xf0, + 0x4a, 0x79, 0x78, 0xa8, 0x75, 0xe9, 0x04, 0xa1, 0x8d, 0xf5, 0xba, 0xcf, 0x7d, 0x9f, 0x46, 0x93, + 0x15, 0x6e, 0xa9, 0x5f, 0x14, 0x34, 0x1f, 0xee, 0x91, 0x85, 0x8b, 0x7b, 0xdb, 0x28, 0x9f, 0x8d, + 0xaf, 0x5f, 0x02, 0x63, 0x84, 0x77, 0xa9, 0x9f, 0x15, 0x74, 0x7b, 0xd0, 0xb8, 0x9e, 0x8d, 0x85, + 0x3f, 0x50, 0x1d, 0x2f, 0x5d, 0xa5, 0x3a, 0xe0, 0xb5, 0xaf, 0x20, 0x35, 0xc4, 0x27, 0x56, 0xc7, + 0x02, 0x1f, 0x06, 0x88, 0xbf, 0xbc, 0x22, 0xc0, 0x39, 0x82, 0x21, 0x36, 0xb0, 0x3a, 0x6e, 0xf7, + 0x03, 0x00, 0x63, 0x12, 0x1c, 0xbd, 0x89, 0xde, 0x77, 0x30, 0x7c, 0x0d, 0x0b, 0x97, 0xd0, 0x60, + 0x90, 0xe6, 0xfa, 0xd5, 0x31, 0x7a, 0x4c, 0xe3, 0x53, 0xef, 0xba, 0x9e, 0x54, 0x58, 0x3e, 0xec, + 0x68, 0xca, 0x51, 0x47, 0x53, 0x7e, 0x77, 0x34, 0xe5, 0xd3, 0xb1, 0x16, 0x39, 0x3a, 0xd6, 0x22, + 0xbf, 0x8e, 0xb5, 0xc8, 0x9b, 0xc5, 0x51, 0xbf, 0xd6, 0xa2, 0xe5, 0x00, 0xaf, 0x4f, 0x7b, 0xff, + 0x4d, 0x1e, 0xff, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x4d, 0x96, 0xfe, 0x14, 0xbd, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1052,20 +1046,18 @@ func (m *MsgAddAllowedIbcToken) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.Percentage != 0 { i = encodeVarintTx(dAtA, i, uint64(m.Percentage)) i-- - dAtA[i] = 0x28 - } - if m.Amount != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Amount)) - i-- dAtA[i] = 0x20 } - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintTx(dAtA, i, uint64(len(m.Denom))) - i-- - dAtA[i] = 0x1a + { + size, err := m.MinFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x1a if len(m.ChannelID) > 0 { i -= len(m.ChannelID) copy(dAtA[i:], m.ChannelID) @@ -1281,13 +1273,8 @@ func (m *MsgAddAllowedIbcToken) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.Denom) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.Amount != 0 { - n += 1 + sovTx(uint64(m.Amount)) - } + l = m.MinFee.Size() + n += 1 + l + sovTx(uint64(l)) if m.Percentage != 0 { n += 1 + sovTx(uint64(m.Percentage)) } @@ -1978,9 +1965,9 @@ func (m *MsgAddAllowedIbcToken) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MinFee", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1990,44 +1977,26 @@ func (m *MsgAddAllowedIbcToken) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Denom = string(dAtA[iNdEx:postIndex]) + if err := m.MinFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) - } - m.Amount = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Amount |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Percentage", wireType) } From 5a272951ba50801a4ef6cba8fbec7d63f26d95d3 Mon Sep 17 00:00:00 2001 From: rustdev Date: Thu, 4 Apr 2024 20:05:57 +0100 Subject: [PATCH 2/2] introduce v6_5_3 --- app/app.go | 4 ++-- app/upgrades/v6_5_3/constants.go | 20 ++++++++++++++++++++ app/upgrades/v6_5_3/upgrade.go | 23 +++++++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 app/upgrades/v6_5_3/constants.go create mode 100644 app/upgrades/v6_5_3/upgrade.go diff --git a/app/app.go b/app/app.go index 97bb8bcf..2905bfb7 100644 --- a/app/app.go +++ b/app/app.go @@ -36,7 +36,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank" "github.com/notional-labs/composable/v6/app/keepers" - "github.com/notional-labs/composable/v6/app/upgrades/v6_5_2" + "github.com/notional-labs/composable/v6/app/upgrades/v6_5_3" // bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" @@ -147,7 +147,7 @@ var ( // https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34 EnableSpecificProposals = "" - Upgrades = []upgrades.Upgrade{v6_5_2.Upgrade} + Upgrades = []upgrades.Upgrade{v6_5_3.Upgrade} Forks = []upgrades.Fork{} ) diff --git a/app/upgrades/v6_5_3/constants.go b/app/upgrades/v6_5_3/constants.go new file mode 100644 index 00000000..509d5d40 --- /dev/null +++ b/app/upgrades/v6_5_3/constants.go @@ -0,0 +1,20 @@ +package v6_5_3 + +import ( + store "github.com/cosmos/cosmos-sdk/store/types" + "github.com/notional-labs/composable/v6/app/upgrades" +) + +const ( + // UpgradeName defines the on-chain upgrade name for the composable upgrade. + UpgradeName = "v6_5_3" +) + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, + StoreUpgrades: store.StoreUpgrades{ + Added: []string{}, + Deleted: []string{}, + }, +} diff --git a/app/upgrades/v6_5_3/upgrade.go b/app/upgrades/v6_5_3/upgrade.go new file mode 100644 index 00000000..405440f8 --- /dev/null +++ b/app/upgrades/v6_5_3/upgrade.go @@ -0,0 +1,23 @@ +package v6_5_3 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/notional-labs/composable/v6/app/keepers" + "github.com/notional-labs/composable/v6/app/upgrades" +) + +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + _ upgrades.BaseAppParamManager, + _ codec.Codec, + keepers *keepers.AppKeepers, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + return mm.RunMigrations(ctx, configurator, vm) + } +}