Skip to content

Commit

Permalink
Merge branch 'master' into cosmovisor-signal
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Nov 13, 2020
2 parents e77b72f + 0b1a3ee commit e4f70ef
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
4 changes: 3 additions & 1 deletion x/ibc/applications/transfer/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,9 @@ func (k Keeper) refundPacketToken(ctx sdk.Context, packet channeltypes.Packet, d
// DenomPathFromHash returns the full denomination path prefix from an ibc denom with a hash
// component.
func (k Keeper) DenomPathFromHash(ctx sdk.Context, denom string) (string, error) {
hexHash := denom[4:]
// trim the denomination prefix, by default "ibc/"
hexHash := denom[len(types.DenomPrefix+"/"):]

hash, err := types.ParseHexHash(hexHash)
if err != nil {
return "", sdkerrors.Wrap(types.ErrInvalidDenomForTransfer, err.Error())
Expand Down
6 changes: 6 additions & 0 deletions x/ibc/applications/transfer/spec/01_concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,9 @@ Cosmos Hub for the `uatom`). Sending a token back to the same chain across a dif
**not** move the token back across its timeline. If a channel in the chain history closes before the
token can be sent back across that channel, then the token will not be returnable to its original
form.


## Security Considerations

For safety, no other module must be capable of minting tokens with the `ibc/` prefix. The IBC
transfer module needs a subset of the denomination space that only it can create tokens in.
3 changes: 3 additions & 0 deletions x/ibc/applications/transfer/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ const (

// QuerierRoute is the querier route for IBC transfer
QuerierRoute = ModuleName

// DenomPrefix is the prefix used for internal SDK coin representation.
DenomPrefix = "ibc"
)

var (
Expand Down
6 changes: 3 additions & 3 deletions x/ibc/applications/transfer/types/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (dt DenomTrace) GetPrefix() string {
// 'ibc/{hash(tracePath + baseDenom)}'. If the trace is empty, it will return the base denomination.
func (dt DenomTrace) IBCDenom() string {
if dt.Path != "" {
return fmt.Sprintf("ibc/%s", dt.Hash())
return fmt.Sprintf("%s/%s", DenomPrefix, dt.Hash())
}
return dt.BaseDenom
}
Expand Down Expand Up @@ -172,8 +172,8 @@ func ValidateIBCDenom(denom string) error {

switch {
case strings.TrimSpace(denom) == "",
len(denomSplit) == 1 && denomSplit[0] == "ibc",
len(denomSplit) == 2 && (denomSplit[0] != "ibc" || strings.TrimSpace(denomSplit[1]) == ""):
len(denomSplit) == 1 && denomSplit[0] == DenomPrefix,
len(denomSplit) == 2 && (denomSplit[0] != DenomPrefix || strings.TrimSpace(denomSplit[1]) == ""):
return sdkerrors.Wrapf(ErrInvalidDenomForTransfer, "denomination should be prefixed with the format 'ibc/{hash(trace + \"/\" + %s)}'", denom)

case denomSplit[0] == denom && strings.TrimSpace(denom) != "":
Expand Down

0 comments on commit e4f70ef

Please sign in to comment.