From a963e77d85b89dc8d5c5a7edc16ff7ceb5a34206 Mon Sep 17 00:00:00 2001 From: Duc Pham Le Date: Wed, 18 May 2022 11:34:37 +0000 Subject: [PATCH] fix ibc error --- Makefile | 2 +- app/app.go | 2 +- .../ibc/applications/transfer/keeper/mbt_relay_test.go | 10 +++++++--- cosmos-sdk/x/ibc/applications/transfer/keeper/relay.go | 6 ++++-- cosmos-sdk/x/ibc/applications/transfer/module.go | 2 +- cosmos-sdk/x/ibc/applications/transfer/types/coin.go | 4 ++-- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 83c568b7..78e75667 100755 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation') #VERSION := $(shell echo $(shell git describe --always) | sed 's/^v//') -VERSION := v0.40.3_ibc +VERSION := v0.40.4_ibc COMMIT := $(shell git log -1 --format='%H') LEDGER_ENABLED ?= false GOMOD_FLAGS ?= -mod=readonly diff --git a/app/app.go b/app/app.go index 1ebf84db..c5a72e85 100755 --- a/app/app.go +++ b/app/app.go @@ -708,7 +708,7 @@ func initParamsKeeper(appCodec codec.BinaryMarshaler, legacyAmino *codec.LegacyA } func (app *OraichainApp) upgradeHandler() { - app.upgradeKeeper.SetUpgradeHandler("v0.40.3_ibc", func(ctx sdk.Context, plan upgradetypes.Plan) { + app.upgradeKeeper.SetUpgradeHandler("v0.40.4_ibc", func(ctx sdk.Context, plan upgradetypes.Plan) { // upgrade changes here }) } diff --git a/cosmos-sdk/x/ibc/applications/transfer/keeper/mbt_relay_test.go b/cosmos-sdk/x/ibc/applications/transfer/keeper/mbt_relay_test.go index defcbbbc..83f4ed07 100755 --- a/cosmos-sdk/x/ibc/applications/transfer/keeper/mbt_relay_test.go +++ b/cosmos-sdk/x/ibc/applications/transfer/keeper/mbt_relay_test.go @@ -31,7 +31,7 @@ type TlaBalance struct { type TlaFungibleTokenPacketData struct { Sender string `json:"sender"` Receiver string `json:"receiver"` - Amount int `json:"amount"` + Amount string `json:"amount"` Denom []string `json:"denom"` } @@ -144,7 +144,7 @@ func FungibleTokenPacketFromTla(packet TlaFungibleTokenPacket) FungibleTokenPack DestPort: packet.DestPort, Data: types.NewFungibleTokenPacketData( DenomFromTla(packet.Data.Denom), - uint64(packet.Data.Amount), + packet.Data.Amount, AddressFromString(packet.Data.Sender), AddressFromString(packet.Data.Receiver)), } @@ -350,11 +350,15 @@ func (suite *KeeperTestSuite) TestModelBasedRelay() { denom := denomTrace.IBCDenom() err = sdk.ValidateDenom(denom) if err == nil { + amount, ok := sdk.NewIntFromString(tc.packet.Data.Amount) + if !ok { + panic("MBT failed to parse amount from string") + } err = suite.chainB.App.TransferKeeper.SendTransfer( suite.chainB.GetContext(), tc.packet.SourcePort, tc.packet.SourceChannel, - sdk.NewCoin(denom, sdk.NewIntFromUint64(tc.packet.Data.Amount)), + sdk.NewCoin(denom, amount), sender, tc.packet.Data.Receiver, clienttypes.NewHeight(0, 110), diff --git a/cosmos-sdk/x/ibc/applications/transfer/keeper/relay.go b/cosmos-sdk/x/ibc/applications/transfer/keeper/relay.go index 9a27acd7..9c65a162 100755 --- a/cosmos-sdk/x/ibc/applications/transfer/keeper/relay.go +++ b/cosmos-sdk/x/ibc/applications/transfer/keeper/relay.go @@ -163,11 +163,13 @@ func (k Keeper) SendTransfer( } defer func() { - telemetry.SetGaugeWithLabels( + if token.Amount.IsInt64() { + telemetry.SetGaugeWithLabels( []string{"tx", "msg", "ibc", "transfer"}, float32(token.Amount.Int64()), []metrics.Label{telemetry.NewLabel(coretypes.LabelDenom, fullDenomPath)}, - ) + ) + } telemetry.IncrCounterWithLabels( []string{"ibc", types.ModuleName, "send"}, diff --git a/cosmos-sdk/x/ibc/applications/transfer/module.go b/cosmos-sdk/x/ibc/applications/transfer/module.go index 8935a0a0..5df32fe2 100755 --- a/cosmos-sdk/x/ibc/applications/transfer/module.go +++ b/cosmos-sdk/x/ibc/applications/transfer/module.go @@ -425,7 +425,7 @@ func (am AppModule) OnTimeoutPacket( sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), sdk.NewAttribute(types.AttributeKeyRefundReceiver, data.Sender), sdk.NewAttribute(types.AttributeKeyRefundDenom, data.Denom), - sdk.NewAttribute(types.AttributeKeyRefundAmount, fmt.Sprintf("%d", data.Amount)), + sdk.NewAttribute(types.AttributeKeyRefundAmount, data.Amount), ), ) diff --git a/cosmos-sdk/x/ibc/applications/transfer/types/coin.go b/cosmos-sdk/x/ibc/applications/transfer/types/coin.go index 08ae9a8d..a3491e2b 100755 --- a/cosmos-sdk/x/ibc/applications/transfer/types/coin.go +++ b/cosmos-sdk/x/ibc/applications/transfer/types/coin.go @@ -42,7 +42,7 @@ func GetPrefixedDenom(portID, channelID, baseDenom string) string { // GetTransferCoin creates a transfer coin with the port ID and channel ID // prefixed to the base denom. -func GetTransferCoin(portID, channelID, baseDenom string, amount int64) sdk.Coin { +func GetTransferCoin(portID, channelID, baseDenom string, amount sdk.Int) sdk.Coin { denomTrace := ParseDenomTrace(GetPrefixedDenom(portID, channelID, baseDenom)) - return sdk.NewInt64Coin(denomTrace.IBCDenom(), amount) + return sdk.NewCoin(denomTrace.IBCDenom(), amount) }