Skip to content

Commit

Permalink
chore: rename decorator to RedundancyRelayDecorator (#1820)
Browse files Browse the repository at this point in the history
* chore: rename decorator to RedundancyRelayDecorator

* add changelog

* renaming

* rename receiver
  • Loading branch information
crodriguezvega authored Jul 28, 2022
1 parent 4a781e5 commit faea729
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (core/04-channel) [\#1792](https://github.com/cosmos/ibc-go/pull/1792) Remove `PreviousChannelID` from `NewMsgChannelOpenTry` arguments. `MsgChannelOpenTry.ValidateBasic()` returns error if the deprecated `PreviousChannelID` is not empty.
* (core/04-channel) [\#1418](https://github.com/cosmos/ibc-go/pull/1418) `NewPacketId` has been renamed to `NewPacketID` to comply with go linting rules.
* (core/ante) [\#1418](https://github.com/cosmos/ibc-go/pull/1418) `AnteDecorator` has been renamed to `RedundancyDecorator` to comply with go linting rules and to give more clarity to the purpose of the Decorator.
* (core/ante) [\#1820](https://github.com/cosmos/ibc-go/pull/1418) `RedundancyDecorator` has been renamed to `RedundantRelayDecorator` to make the name for explicit.
* (testing) [\#1418](https://github.com/cosmos/ibc-go/pull/1418) `MockIBCApp` has been renamed to `IBCApp` and `MockEmptyAcknowledgement` has been renamed to `EmptyAcknowledgement` to comply with go linting rules
* (modules/core/03-connection) [\#1672](https://github.com/cosmos/ibc-go/pull/1672) Remove crossing hellos from connection handshakes. The `PreviousConnectionId` in `MsgConnectionOpenTry` has been deprecated.
* (modules/core/04-channel) [\#1317](https://github.com/cosmos/ibc-go/pull/1317) Remove crossing hellos from channel handshakes. The `PreviousChannelId` in `MsgChannelOpenTry` has been deprecated.
Expand Down
20 changes: 10 additions & 10 deletions modules/core/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ import (
"github.com/cosmos/ibc-go/v5/modules/core/keeper"
)

type RedundancyDecorator struct {
type RedundantRelayDecorator struct {
k *keeper.Keeper
}

func NewRedundancyDecorator(k *keeper.Keeper) RedundancyDecorator {
return RedundancyDecorator{k: k}
func NewRedundantRelayDecorator(k *keeper.Keeper) RedundantRelayDecorator {
return RedundantRelayDecorator{k: k}
}

// RedundancyDecorator returns an error if a multiMsg tx only contains packet messages (Recv, Ack, Timeout) and additional update messages
// RedundantRelayDecorator returns an error if a multiMsg tx only contains packet messages (Recv, Ack, Timeout) and additional update messages
// and all packet messages are redundant. If the transaction is just a single UpdateClient message, or the multimsg transaction
// contains some other message type, then the antedecorator returns no error and continues processing to ensure these transactions
// are included. This will ensure that relayers do not waste fees on multiMsg transactions when another relayer has already submitted
// all packets, by rejecting the tx at the mempool layer.
func (rd RedundancyDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
func (rrd RedundantRelayDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
// do not run redundancy check on DeliverTx or simulate
if (ctx.IsCheckTx() || ctx.IsReCheckTx()) && !simulate {
// keep track of total packet messages and number of redundancies across `RecvPacket`, `AcknowledgePacket`, and `TimeoutPacket/OnClose`
Expand All @@ -30,7 +30,7 @@ func (rd RedundancyDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo
for _, m := range tx.GetMsgs() {
switch msg := m.(type) {
case *channeltypes.MsgRecvPacket:
response, err := rd.k.RecvPacket(sdk.WrapSDKContext(ctx), msg)
response, err := rrd.k.RecvPacket(sdk.WrapSDKContext(ctx), msg)
if err != nil {
return ctx, err
}
Expand All @@ -40,7 +40,7 @@ func (rd RedundancyDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo
packetMsgs++

case *channeltypes.MsgAcknowledgement:
response, err := rd.k.Acknowledgement(sdk.WrapSDKContext(ctx), msg)
response, err := rrd.k.Acknowledgement(sdk.WrapSDKContext(ctx), msg)
if err != nil {
return ctx, err
}
Expand All @@ -50,7 +50,7 @@ func (rd RedundancyDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo
packetMsgs++

case *channeltypes.MsgTimeout:
response, err := rd.k.Timeout(sdk.WrapSDKContext(ctx), msg)
response, err := rrd.k.Timeout(sdk.WrapSDKContext(ctx), msg)
if err != nil {
return ctx, err
}
Expand All @@ -60,7 +60,7 @@ func (rd RedundancyDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo
packetMsgs++

case *channeltypes.MsgTimeoutOnClose:
response, err := rd.k.TimeoutOnClose(sdk.WrapSDKContext(ctx), msg)
response, err := rrd.k.TimeoutOnClose(sdk.WrapSDKContext(ctx), msg)
if err != nil {
return ctx, err
}
Expand All @@ -70,7 +70,7 @@ func (rd RedundancyDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo
packetMsgs++

case *clienttypes.MsgUpdateClient:
_, err := rd.k.UpdateClient(sdk.WrapSDKContext(ctx), msg)
_, err := rrd.k.UpdateClient(sdk.WrapSDKContext(ctx), msg)
if err != nil {
return ctx, err
}
Expand Down
4 changes: 2 additions & 2 deletions modules/core/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() {
// committing it to a block, so that the when check tx runs with the redundant
// message they are both in the same block
k := suite.chainB.App.GetIBCKeeper()
decorator := ante.NewRedundancyDecorator(k)
decorator := ante.NewRedundantRelayDecorator(k)
checkCtx := suite.chainB.GetContext().WithIsCheckTx(true)
next := func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) { return ctx, nil }
txBuilder := suite.chainB.TxConfig.NewTxBuilder()
Expand All @@ -458,7 +458,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() {
suite.SetupTest()

k := suite.chainB.App.GetIBCKeeper()
decorator := ante.NewRedundancyDecorator(k)
decorator := ante.NewRedundantRelayDecorator(k)

msgs := tc.malleate(suite)

Expand Down
2 changes: 1 addition & 1 deletion testing/simapp/ante_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
ante.NewSigGasConsumeDecorator(options.AccountKeeper, sigGasConsumer),
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
ibcante.NewRedundancyDecorator(options.IBCKeeper),
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
}

return sdk.ChainAnteDecorators(anteDecorators...), nil
Expand Down

0 comments on commit faea729

Please sign in to comment.