Skip to content

Commit

Permalink
Fixed denom metadata source chain-id retrieval for new ibc markers (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
nullpointer0x00 authored Nov 8, 2023
1 parent d050e97 commit ccdf057
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions app/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions x/ibchooks/marker_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}
Expand Down

0 comments on commit ccdf057

Please sign in to comment.