Skip to content
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

replace channel keeper with IBC keeper in AnteDecorator #950

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
review comments and some fixes
  • Loading branch information
Carlos Rodriguez committed Mar 4, 2022
commit 1d4d8527ab3f7a2e9952430b1227f498f6a0d969
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (testing) [\#776](https://github.com/cosmos/ibc-go/pull/776) Adding helper fn to generate capability name for testing callbacks
* (testing) [\#892](https://github.com/cosmos/ibc-go/pull/892) IBC Mock modules store the scoped keeper and portID within the IBCMockApp. They also maintain reference to the AppModule to update the AppModule's list of IBC applications it references. Allows for the mock module to be reused as a base application in middleware stacks.
* (channel) [\#882](https://github.com/cosmos/ibc-go/pull/882) The `WriteAcknowledgement` API now takes `exported.Acknowledgement` instead of a byte array
* (modules/core/ante) [\#950](https://github.com/cosmos/ibc-go/pull/950) Replaces the channel keeper with the IBC keeper in the IBC `AnteDecorator` in order to execute the entire message and be able to reject redundant messages that are in the same block as the non-redundant messages.

### State Machine Breaking

Expand Down
32 changes: 20 additions & 12 deletions modules/core/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,43 @@ func (ad AnteDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, ne
for _, m := range tx.GetMsgs() {
switch msg := m.(type) {
case *channeltypes.MsgRecvPacket:
if response, err := ad.k.RecvPacket(sdk.WrapSDKContext(ctx), msg); err == nil && response.Result == channeltypes.NOOP {
redundancies += 1
} else if err != nil {
response, err := ad.k.RecvPacket(sdk.WrapSDKContext(ctx), msg)
if err != nil {
return ctx, err
}
if response.Result == channeltypes.NOOP {
redundancies += 1
}
packetMsgs += 1

case *channeltypes.MsgAcknowledgement:
if response, err := ad.k.Acknowledgement(sdk.WrapSDKContext(ctx), msg); err == nil && response.Result == channeltypes.NOOP {
redundancies += 1
} else if err != nil {
response, err := ad.k.Acknowledgement(sdk.WrapSDKContext(ctx), msg)
if err != nil {
return ctx, err
}
if response.Result == channeltypes.NOOP {
redundancies += 1
}
packetMsgs += 1

case *channeltypes.MsgTimeout:
if response, err := ad.k.Timeout(sdk.WrapSDKContext(ctx), msg); err == nil && response.Result == channeltypes.NOOP {
redundancies += 1
} else if err != nil {
response, err := ad.k.Timeout(sdk.WrapSDKContext(ctx), msg)
if err != nil {
return ctx, err
}
if response.Result == channeltypes.NOOP {
redundancies += 1
}
packetMsgs += 1

case *channeltypes.MsgTimeoutOnClose:
if response, err := ad.k.TimeoutOnClose(sdk.WrapSDKContext(ctx), msg); err == nil && response.Result == channeltypes.NOOP {
redundancies += 1
} else if err != nil {
response, err := ad.k.TimeoutOnClose(sdk.WrapSDKContext(ctx), msg)
if err != nil {
return ctx, err
}
if response.Result == channeltypes.NOOP {
redundancies += 1
}
packetMsgs += 1

case *clienttypes.MsgUpdateClient:
Expand Down
4 changes: 3 additions & 1 deletion modules/core/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,9 @@ func (suite *AnteTestSuite) TestAnteDecorator() {
func(suite *AnteTestSuite) []sdk.Msg {
msg := suite.createRecvPacketMessage(uint64(1), false)

// run check tx with non-redundant message
// We want to be able to run check tx with the non-redundant message without
// commiting 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.NewAnteDecorator(k)
checkCtx := suite.chainB.GetContext().WithIsCheckTx(true)
Expand Down
2 changes: 1 addition & 1 deletion testing/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ func (endpoint *Endpoint) TimeoutOnClose(packet channeltypes.Packet) error {
proofClosed, _ := endpoint.Counterparty.QueryProof(channelKey)

nextSeqRecv, found := endpoint.Counterparty.Chain.App.GetIBCKeeper().ChannelKeeper.GetNextSequenceRecv(endpoint.Counterparty.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID)
require.True(endpoint.Chain.t, found)
require.True(endpoint.Chain.T, found)

timeoutOnCloseMsg := channeltypes.NewMsgTimeoutOnClose(
packet, nextSeqRecv,
Expand Down
2 changes: 1 addition & 1 deletion testing/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ func NewSimApp(
FeegrantKeeper: app.FeeGrantKeeper,
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
},
IBCkeeper: app.IBCKeeper,
IBCKeeper: app.IBCKeeper,
},
)
if err != nil {
Expand Down