-
Notifications
You must be signed in to change notification settings - Fork 593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(migration): metadata migration was incorrect #7525
Closed
Closed
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,8 +43,9 @@ func (m Migrator) MigrateDenomMetadata(ctx sdk.Context) error { | |
m.keeper.iterateDenomTraces(ctx, | ||
func(dt internaltypes.DenomTrace) (stop bool) { | ||
// check if the metadata for the given denom trace does not already exist | ||
if !m.keeper.bankKeeper.HasDenomMetaData(ctx, dt.IBCDenom()) { | ||
m.keeper.setDenomMetadataWithDenomTrace(ctx, dt) | ||
denom, present := m.keeper.bankKeeper.GetDenomMetaData(ctx, dt.IBCDenom()) | ||
if !present { | ||
m.keeper.setDenomMetadataWithDenomTrace(ctx, dt, denom) | ||
} | ||
return false | ||
}) | ||
|
@@ -146,15 +147,19 @@ func (k Keeper) iterateDenomTraces(ctx context.Context, cb func(denomTrace inter | |
} | ||
|
||
// setDenomMetadataWithDenomTrace sets an IBC token's denomination metadata | ||
func (k Keeper) setDenomMetadataWithDenomTrace(ctx sdk.Context, denomTrace internaltypes.DenomTrace) { | ||
func (k Keeper) setDenomMetadataWithDenomTrace(ctx sdk.Context, denomTrace internaltypes.DenomTrace, denomMetadata banktypes.Metadata) { | ||
du := make([]*banktypes.DenomUnit, 0, len(denomMetadata.DenomUnits)) | ||
|
||
for _, dunit := range denomMetadata.DenomUnits { | ||
du = append(du, &banktypes.DenomUnit{ | ||
Denom: dunit.Denom, | ||
Exponent: dunit.Exponent, | ||
Aliases: dunit.Aliases, | ||
}) | ||
} | ||
Comment on lines
+153
to
+159
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand how this code is reachable. |
||
metadata := banktypes.Metadata{ | ||
Description: fmt.Sprintf("IBC token from %s", denomTrace.GetFullDenomPath()), | ||
DenomUnits: []*banktypes.DenomUnit{ | ||
{ | ||
Denom: denomTrace.BaseDenom, | ||
Exponent: 0, | ||
}, | ||
}, | ||
DenomUnits: du, | ||
// Setting base as IBC hash denom since bank keepers's SetDenomMetadata uses | ||
// Base as key path and the IBC hash is what gives this token uniqueness | ||
// on the executing chain | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there exists a denom metadata we will not overwrite it.
The only scenario in which this can overwrite an existing denom metadata, entering the if branch here is:
Collections/Map.Has
(ref) returnshas == true
but also hits an error for some reason out of our control, meaning thaterr != nil
inHasDenomMetaData
here. This would yield a falsey return value and we'd enter if and overwrite the underlying denom metadataThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it is possible that the key constructed in an old version differs from the key constructed in a new version. We should verify that all non-ibc denom metadata's are queryable