Skip to content

Commit

Permalink
remove provider changes and fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
mpoke committed Nov 6, 2024
1 parent eb4336f commit e1906aa
Show file tree
Hide file tree
Showing 15 changed files with 16 additions and 2,949 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
- `[x/consumer]` Populate the memo on the IBC transfer packets used to send ICS rewards.
with the required consumer chain Id to identify the consumer to the provider.
- `[x/provider]` Identify the source of ICS rewards from the IBC transfer packet memo.
([\#2290](https://github.com/cosmos/interchain-security/pull/2290))
([\#2387](https://github.com/cosmos/interchain-security/pull/2387))
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
- `[x/consumer]` Populate the memo on the IBC transfer packets used to send ICS rewards.
with the required consumer chain Id to identify the consumer to the provider.
- `[x/provider]` Identify the source of ICS rewards from the IBC transfer packet memo.
([\#2290](https://github.com/cosmos/interchain-security/pull/2290))
([\#2387](https://github.com/cosmos/interchain-security/pull/2387))
8 changes: 7 additions & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Upgrading Replicated Security

## v5.2.x
## v5.3.x

### Provider

***This release does not affect the provider chains.***

### Consumer

Expand All @@ -22,6 +26,8 @@ func InitializeConsumerId(ctx sdk.Context, consumerKeeper consumerkeeper.Keeper)
}
```

## v5.2.x

### Provider

Providers using versions `v5.1.x` can upgrade to `v5.2.x`.
Expand Down
69 changes: 0 additions & 69 deletions x/ccv/provider/ibc_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,8 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"

<<<<<<< HEAD
"github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper"
"github.com/cosmos/interchain-security/v5/x/ccv/provider/types"
=======
"github.com/cosmos/interchain-security/v6/x/ccv/provider/keeper"
"github.com/cosmos/interchain-security/v6/x/ccv/provider/types"
ccvtypes "github.com/cosmos/interchain-security/v6/x/ccv/types"
>>>>>>> 0d782959 (feat!: add memo to IBC transfers of ICS rewards (#2290))
)

var _ porttypes.Middleware = &IBCMiddleware{}
Expand Down Expand Up @@ -127,15 +121,12 @@ func (im IBCMiddleware) OnRecvPacket(
// that the packet data is valid and can be safely
// deserialized without checking errors.
if ack.Success() {
<<<<<<< HEAD
// execute the middleware logic only if the sender is a consumer chain
consumerID, err := im.keeper.IdentifyConsumerChainIDFromIBCPacket(ctx, packet)
if err != nil {
return ack
}

=======
>>>>>>> 0d782959 (feat!: add memo to IBC transfers of ICS rewards (#2290))
// extract the coin info received from the packet data
var data ibctransfertypes.FungibleTokenPacketData
_ = types.ModuleCdc.UnmarshalJSON(packet.GetData(), &data)
Expand All @@ -146,68 +137,8 @@ func (im IBCMiddleware) OnRecvPacket(
return ack
}

<<<<<<< HEAD
coinAmt, _ := math.NewIntFromString(data.Amount)
coinDenom := GetProviderDenom(data.Denom, packet)
=======
consumerId := ""
// check if the transfer has the reward memo
if rewardMemo, err := ccvtypes.GetRewardMemoFromTransferMemo(data.Memo); err != nil {
// check if the transfer is on a channel with the same underlying
// client as the CCV channel
consumerId, err = im.keeper.IdentifyConsumerIdFromIBCPacket(ctx, packet)
if err != nil {
if data.Memo == "consumer chain rewards distribution" {
// log error message
logger.Error(
"received token transfer with ICS reward from unknown consumer",
"packet", packet.String(),
"fungibleTokenPacketData", data.String(),
"error", err.Error(),
)
}

return ack
}
} else {
logger.Info("transfer memo:%#+v", rewardMemo)
consumerId = rewardMemo.ConsumerId
}

coinAmt, _ := math.NewIntFromString(data.Amount)
coinDenom := GetProviderDenom(data.Denom, packet)
chainId, err := im.keeper.GetConsumerChainId(ctx, consumerId)
if err != nil {
logger.Error(
"cannot get consumer chain id in transfer middleware",
"consumerId", consumerId,
"packet", packet.String(),
"fungibleTokenPacketData", data.String(),
"error", err.Error(),
)
return ack
}

logger.Info(
"received ICS rewards from consumer chain",
"consumerId", consumerId,
"chainId", chainId,
"denom", coinDenom,
"amount", data.Amount,
)

// initialize an empty slice to store event attributes
eventAttributes := []sdk.Attribute{}

// add event attributes
eventAttributes = append(eventAttributes, []sdk.Attribute{
sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
sdk.NewAttribute(types.AttributeConsumerId, consumerId),
sdk.NewAttribute(types.AttributeConsumerChainId, chainId),
sdk.NewAttribute(types.AttributeRewardDenom, coinDenom),
sdk.NewAttribute(types.AttributeRewardAmount, data.Amount),
}...)
>>>>>>> 0d782959 (feat!: add memo to IBC transfers of ICS rewards (#2290))

// verify that the coin's denom is a whitelisted consumer denom,
// and if so, adds it to the consumer chain rewards allocation,
Expand Down
Loading

0 comments on commit e1906aa

Please sign in to comment.