From ea67cee11d9ede42e663b512cff2f18a4c9828f3 Mon Sep 17 00:00:00 2001 From: crodriguezvega Date: Thu, 28 Jul 2022 13:30:57 +0200 Subject: [PATCH 1/4] chore: rename decorator to RedundancyRelayDecorator --- modules/core/ante/ante.go | 10 +++++----- modules/core/ante/ante_test.go | 4 ++-- testing/simapp/ante_handler.go | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/core/ante/ante.go b/modules/core/ante/ante.go index 14206b40ef0..702534695e1 100644 --- a/modules/core/ante/ante.go +++ b/modules/core/ante/ante.go @@ -8,20 +8,20 @@ import ( "github.com/cosmos/ibc-go/v5/modules/core/keeper" ) -type RedundancyDecorator struct { +type RedundancyRelayDecorator struct { k *keeper.Keeper } -func NewRedundancyDecorator(k *keeper.Keeper) RedundancyDecorator { - return RedundancyDecorator{k: k} +func NewRedundancyRelayDecorator(k *keeper.Keeper) RedundancyRelayDecorator { + return RedundancyRelayDecorator{k: k} } -// RedundancyDecorator returns an error if a multiMsg tx only contains packet messages (Recv, Ack, Timeout) and additional update messages +// RedundancyRelayDecorator 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 (rd RedundancyRelayDecorator) 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` diff --git a/modules/core/ante/ante_test.go b/modules/core/ante/ante_test.go index 79c7bfa4264..2ceff3ec728 100644 --- a/modules/core/ante/ante_test.go +++ b/modules/core/ante/ante_test.go @@ -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.NewRedundancyRelayDecorator(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() @@ -458,7 +458,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() { suite.SetupTest() k := suite.chainB.App.GetIBCKeeper() - decorator := ante.NewRedundancyDecorator(k) + decorator := ante.NewRedundancyRelayDecorator(k) msgs := tc.malleate(suite) diff --git a/testing/simapp/ante_handler.go b/testing/simapp/ante_handler.go index 84621c75883..10019763962 100644 --- a/testing/simapp/ante_handler.go +++ b/testing/simapp/ante_handler.go @@ -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.NewRedundancyRelayDecorator(options.IBCKeeper), } return sdk.ChainAnteDecorators(anteDecorators...), nil From c1139be2e896a41da1ea80c05fdff3c3d9b8244b Mon Sep 17 00:00:00 2001 From: crodriguezvega Date: Thu, 28 Jul 2022 13:33:05 +0200 Subject: [PATCH 2/4] add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3eb7ce5b5cb..145f4faa59b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (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 `RedundancRelayDecorator` 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. From 49518777d20fa786678cb29f8fd81c36a5262cb1 Mon Sep 17 00:00:00 2001 From: crodriguezvega Date: Thu, 28 Jul 2022 13:49:30 +0200 Subject: [PATCH 3/4] renaming --- CHANGELOG.md | 2 +- modules/core/ante/ante.go | 10 +++++----- modules/core/ante/ante_test.go | 4 ++-- testing/simapp/ante_handler.go | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 145f4faa59b..19e6888d976 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,7 +45,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (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 `RedundancRelayDecorator` to make the name for explicit. +* (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. diff --git a/modules/core/ante/ante.go b/modules/core/ante/ante.go index 702534695e1..fdc1c3c3fee 100644 --- a/modules/core/ante/ante.go +++ b/modules/core/ante/ante.go @@ -8,20 +8,20 @@ import ( "github.com/cosmos/ibc-go/v5/modules/core/keeper" ) -type RedundancyRelayDecorator struct { +type RedundantRelayDecorator struct { k *keeper.Keeper } -func NewRedundancyRelayDecorator(k *keeper.Keeper) RedundancyRelayDecorator { - return RedundancyRelayDecorator{k: k} +func NewRedundantRelayDecorator(k *keeper.Keeper) RedundantRelayDecorator { + return RedundantRelayDecorator{k: k} } -// RedundancyRelayDecorator 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 RedundancyRelayDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { +func (rd 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` diff --git a/modules/core/ante/ante_test.go b/modules/core/ante/ante_test.go index 2ceff3ec728..3d074429a66 100644 --- a/modules/core/ante/ante_test.go +++ b/modules/core/ante/ante_test.go @@ -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.NewRedundancyRelayDecorator(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() @@ -458,7 +458,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() { suite.SetupTest() k := suite.chainB.App.GetIBCKeeper() - decorator := ante.NewRedundancyRelayDecorator(k) + decorator := ante.NewRedundantRelayDecorator(k) msgs := tc.malleate(suite) diff --git a/testing/simapp/ante_handler.go b/testing/simapp/ante_handler.go index 10019763962..581140150b1 100644 --- a/testing/simapp/ante_handler.go +++ b/testing/simapp/ante_handler.go @@ -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.NewRedundancyRelayDecorator(options.IBCKeeper), + ibcante.NewRedundantRelayDecorator(options.IBCKeeper), } return sdk.ChainAnteDecorators(anteDecorators...), nil From d08205694a1a32994a29f6d69661c35bda0bae8b Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Thu, 28 Jul 2022 16:49:10 +0200 Subject: [PATCH 4/4] rename receiver --- modules/core/ante/ante.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/core/ante/ante.go b/modules/core/ante/ante.go index fdc1c3c3fee..48caef7bff5 100644 --- a/modules/core/ante/ante.go +++ b/modules/core/ante/ante.go @@ -21,7 +21,7 @@ func NewRedundantRelayDecorator(k *keeper.Keeper) RedundantRelayDecorator { // 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 RedundantRelayDecorator) 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` @@ -30,7 +30,7 @@ func (rd RedundantRelayDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulat 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 } @@ -40,7 +40,7 @@ func (rd RedundantRelayDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulat 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 } @@ -50,7 +50,7 @@ func (rd RedundantRelayDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulat 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 } @@ -60,7 +60,7 @@ func (rd RedundantRelayDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulat 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 } @@ -70,7 +70,7 @@ func (rd RedundantRelayDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulat 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 }