From ccdf0577544f44546d1acf359870d8bd68bad7ca Mon Sep 17 00:00:00 2001 From: Carlton Hanna Date: Wed, 8 Nov 2023 16:48:01 -0700 Subject: [PATCH] Fixed denom metadata source chain-id retrieval for new ibc markers (#1738) * should be using packet dest port and channel to get the correct source chain id * fix compile error * add upgrade handler for rc3, add changelog --- CHANGELOG.md | 1 + app/upgrades.go | 13 +++++++++++++ app/upgrades_test.go | 9 +++++++++ x/ibchooks/marker_hooks.go | 6 +++--- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb9e32faaf..152ad7ae9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * During `InitGenesis`, ensure LastOrderId is at least the largest order id [#1699](https://github.com/provenance-io/provenance/issues/1699). * Properly populate the permissions lists when reading access grants from state [#1699](https://github.com/provenance-io/provenance/issues/1699). * Fixed the paginated order queries to properly look up orders [#1699](https://github.com/provenance-io/provenance/issues/1699). +* Fixed denom metadata source chain-id retrieval for new ibc markers [#1726](https://github.com/provenance-io/provenance/issues/1726). ### Dependencies diff --git a/app/upgrades.go b/app/upgrades.go index dcd1945508..9254bac161 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -137,6 +137,19 @@ var upgrades = map[string]appUpgrade{ return vm, nil }, }, + "saffron-rc3": { // upgrade for v1.17.0-rc3 + Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) { + var err error + vm, err = runModuleMigrations(ctx, app, vm) + if err != nil { + return nil, err + } + + updateIbcMarkerDenomMetadata(ctx, app) + + return vm, nil + }, + }, "saffron": { // upgrade for v1.17.0, Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) { var err error diff --git a/app/upgrades_test.go b/app/upgrades_test.go index 1a7aa2a0bc..8628ce4471 100644 --- a/app/upgrades_test.go +++ b/app/upgrades_test.go @@ -445,6 +445,15 @@ func (s *UpgradeTestSuite) TestSaffronRC2() { s.AssertUpgradeHandlerLogs("saffron-rc2", expInLog, nil) } +func (s *UpgradeTestSuite) TestSaffronRC3() { + expInLog := []string{ + "INF Updating ibc marker denom metadata", + "INF Done updating ibc marker denom metadata", + } + + s.AssertUpgradeHandlerLogs("saffron-rc3", expInLog, nil) +} + func (s *UpgradeTestSuite) TestSaffron() { // Each part is (hopefully) tested thoroughly on its own. // So for this test, just make sure there's log entries for each part being done. diff --git a/x/ibchooks/marker_hooks.go b/x/ibchooks/marker_hooks.go index 73f86e61e9..57cd9faa00 100644 --- a/x/ibchooks/marker_hooks.go +++ b/x/ibchooks/marker_hooks.go @@ -114,7 +114,7 @@ func (h MarkerHooks) getExistingSupply(ctx sdktypes.Context, marker *markertypes // addDenomMetaData adds denom metadata for ibc token func (h MarkerHooks) addDenomMetaData(ctx sdktypes.Context, packet exported.PacketI, ibcKeeper *ibckeeper.Keeper, ibcDenom string, data transfertypes.FungibleTokenPacketData) error { - chainID := h.GetChainID(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), ibcKeeper) + chainID := h.GetChainID(ctx, packet.GetDestPort(), packet.GetDestChannel(), ibcKeeper) markerMetadata := banktypes.Metadata{ Base: ibcDenom, Name: chainID + "/" + data.Denom, @@ -125,9 +125,9 @@ func (h MarkerHooks) addDenomMetaData(ctx sdktypes.Context, packet exported.Pack } // GetChainID returns the source chain id from packet for a `07-tendermint` client connection or returns `unknown` -func (h MarkerHooks) GetChainID(ctx sdktypes.Context, sourcePort, sourceChannel string, ibcKeeper *ibckeeper.Keeper) string { +func (h MarkerHooks) GetChainID(ctx sdktypes.Context, ibcPort, ibcChannel string, ibcKeeper *ibckeeper.Keeper) string { chainID := "unknown" - channel, found := ibcKeeper.ChannelKeeper.GetChannel(ctx, sourcePort, sourceChannel) + channel, found := ibcKeeper.ChannelKeeper.GetChannel(ctx, ibcPort, ibcChannel) if !found { return chainID }