From d3a3b6d468ecd905a8240e3f4083b17174d9fbe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Thu, 29 Jun 2023 18:14:26 +0200 Subject: [PATCH 1/2] fix: apply SDK app hash fix --- go.mod | 4 +- go.sum | 8 ++-- .../apps/transfer/keeper/msg_server_test.go | 2 +- .../transfer/types/transfer_authorization.go | 19 ++++---- .../types/transfer_authorization_test.go | 22 ++++----- modules/capability/go.mod | 2 +- testing/chain.go | 21 ++++++--- testing/endpoint.go | 7 +-- testing/events.go | 14 +++--- testing/simapp/export.go | 5 +- testing/simapp/test_helpers.go | 46 ++++--------------- testing/solomachine.go | 7 +-- 12 files changed, 67 insertions(+), 90 deletions(-) diff --git a/go.mod b/go.mod index aa113c8db88..b3c72c95fb8 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ module github.com/cosmos/ibc-go/v7 require ( cosmossdk.io/api v0.4.3-0.20230620040119-e078f1a49e8b cosmossdk.io/client/v2 v2.0.0-20230615173548-5385116abac4 - cosmossdk.io/core v0.8.0 + cosmossdk.io/core v0.9.0 cosmossdk.io/depinject v1.0.0-alpha.3 cosmossdk.io/errors v1.0.0-beta.7.0.20230524212735-6cabb6aa5741 cosmossdk.io/log v1.1.0 @@ -197,6 +197,6 @@ require ( replace github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // replace with the main branch, contianing the apphash fix -replace github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230628150442-76ade5fa31a5 +replace github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.50.0-alpha.0.0.20230629143215-6172a1a0bf9b replace github.com/cosmos/ibc-go/modules/capability => ./modules/capability diff --git a/go.sum b/go.sum index c6ff6da858b..5bb462a86eb 100644 --- a/go.sum +++ b/go.sum @@ -194,8 +194,8 @@ cosmossdk.io/client/v2 v2.0.0-20230615173548-5385116abac4 h1:hRgwSTe49l1S+nA4l4A cosmossdk.io/client/v2 v2.0.0-20230615173548-5385116abac4/go.mod h1:0LYJm2+vdRIRDSP4yZZMGn68z6ZAFyLC0kuK31zXsOk= cosmossdk.io/collections v0.2.1-0.20230620134406-d4f1e88b6531 h1:6CxleI/IgdENrujwTY2yY9Wg52DVZr4eq4L71ANoLuQ= cosmossdk.io/collections v0.2.1-0.20230620134406-d4f1e88b6531/go.mod h1:k8IKBKC/lO+BKoIGae3RC8NCBV8+7JaAw+es51YylFs= -cosmossdk.io/core v0.8.0 h1:LcJnu52E1a8f8E317VfQ1xK/RZe+IuhMNQAjnDLh25M= -cosmossdk.io/core v0.8.0/go.mod h1:LF6VLOv2DdCiaHxYVmr0MZcZpaSM9ZgvyrQSYTeg6D0= +cosmossdk.io/core v0.9.0 h1:30ScAOHDIUOCg1DKAwqkho9wuQJnu7GUrMcg0XLioic= +cosmossdk.io/core v0.9.0/go.mod h1:NFgl5r41Q36+RixTvyrfsS6qQ65agCbZ1FTpnN7/G1Y= cosmossdk.io/depinject v1.0.0-alpha.3 h1:6evFIgj//Y3w09bqOUOzEpFj5tsxBqdc5CfkO7z+zfw= cosmossdk.io/depinject v1.0.0-alpha.3/go.mod h1:eRbcdQ7MRpIPEM5YUJh8k97nxHpYbc3sMUnEtt8HPWU= cosmossdk.io/errors v1.0.0-beta.7.0.20230524212735-6cabb6aa5741 h1:BCRz06fvddw7cKGiEGDiSox3qMsjQ97f92K+PDZDHdc= @@ -351,8 +351,8 @@ github.com/cosmos/cosmos-db v1.0.0 h1:EVcQZ+qYag7W6uorBKFPvX6gRjw6Uq2hIh4hCWjuQ0 github.com/cosmos/cosmos-db v1.0.0/go.mod h1:iBvi1TtqaedwLdcrZVYRSSCb6eSy61NLj4UNmdIgs0U= github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= -github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230628150442-76ade5fa31a5 h1:NMcL4LKDvu51yiAZBbjCZGTH/M+MfUkq4Jld4QyNsSw= -github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230628150442-76ade5fa31a5/go.mod h1:6bhpmPC0p3AgJC4jNKImoSFcQSG1xlq8QgL2Uc4yc4U= +github.com/cosmos/cosmos-sdk v0.50.0-alpha.0.0.20230629143215-6172a1a0bf9b h1:7U9laUmlfVKEUwcFC2mDhfdyC3Ygxm4GlJEFAhrH41c= +github.com/cosmos/cosmos-sdk v0.50.0-alpha.0.0.20230629143215-6172a1a0bf9b/go.mod h1:10q0oPIC2/RZEWlGesvLsQtQDXEPnh2bF1rRf/mwAEk= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= diff --git a/modules/apps/transfer/keeper/msg_server_test.go b/modules/apps/transfer/keeper/msg_server_test.go index 29a94e204da..f6a8cb429c6 100644 --- a/modules/apps/transfer/keeper/msg_server_test.go +++ b/modules/apps/transfer/keeper/msg_server_test.go @@ -104,7 +104,7 @@ func (suite *KeeperTestSuite) TestMsgTransfer() { res, err := suite.chainA.GetSimApp().TransferKeeper.Transfer(ctx, msg) // Verify events - events := ctx.EventManager().Events() + events := ctx.EventManager().Events().ToABCIEvents() expEvents := ibctesting.EventsMap{ "ibc_transfer": { "sender": suite.chainA.SenderAccount.GetAddress().String(), diff --git a/modules/apps/transfer/types/transfer_authorization.go b/modules/apps/transfer/types/transfer_authorization.go index 3ffd2cbaa83..13d05078080 100644 --- a/modules/apps/transfer/types/transfer_authorization.go +++ b/modules/apps/transfer/types/transfer_authorization.go @@ -10,7 +10,6 @@ import ( sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - authztypes "github.com/cosmos/cosmos-sdk/types/authz" "github.com/cosmos/cosmos-sdk/x/authz" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" @@ -36,12 +35,12 @@ func (a TransferAuthorization) MsgTypeURL() string { } // Accept implements Authorization.Accept. -func (a TransferAuthorization) Accept(ctx context.Context, msg proto.Message) (authztypes.AcceptResponse, error) { +func (a TransferAuthorization) Accept(ctx context.Context, msg proto.Message) (authz.AcceptResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) msgTransfer, ok := msg.(*MsgTransfer) if !ok { - return authztypes.AcceptResponse{}, errorsmod.Wrap(ibcerrors.ErrInvalidType, "type mismatch") + return authz.AcceptResponse{}, errorsmod.Wrap(ibcerrors.ErrInvalidType, "type mismatch") } for index, allocation := range a.Allocations { @@ -50,25 +49,25 @@ func (a TransferAuthorization) Accept(ctx context.Context, msg proto.Message) (a } if !isAllowedAddress(sdkCtx, msgTransfer.Receiver, allocation.AllowList) { - return authztypes.AcceptResponse{}, errorsmod.Wrap(ibcerrors.ErrInvalidAddress, "not allowed receiver address for transfer") + return authz.AcceptResponse{}, errorsmod.Wrap(ibcerrors.ErrInvalidAddress, "not allowed receiver address for transfer") } // If the spend limit is set to the MaxUint256 sentinel value, do not subtract the amount from the spend limit. if allocation.SpendLimit.AmountOf(msgTransfer.Token.Denom).Equal(UnboundedSpendLimit()) { - return authztypes.AcceptResponse{Accept: true, Delete: false, Updated: nil}, nil + return authz.AcceptResponse{Accept: true, Delete: false, Updated: nil}, nil } limitLeft, isNegative := allocation.SpendLimit.SafeSub(msgTransfer.Token) if isNegative { - return authztypes.AcceptResponse{}, errorsmod.Wrapf(ibcerrors.ErrInsufficientFunds, "requested amount is more than spend limit") + return authz.AcceptResponse{}, errorsmod.Wrapf(ibcerrors.ErrInsufficientFunds, "requested amount is more than spend limit") } if limitLeft.IsZero() { a.Allocations = append(a.Allocations[:index], a.Allocations[index+1:]...) if len(a.Allocations) == 0 { - return authztypes.AcceptResponse{Accept: true, Delete: true}, nil + return authz.AcceptResponse{Accept: true, Delete: true}, nil } - return authztypes.AcceptResponse{Accept: true, Delete: false, Updated: &TransferAuthorization{ + return authz.AcceptResponse{Accept: true, Delete: false, Updated: &TransferAuthorization{ Allocations: a.Allocations, }}, nil } @@ -79,12 +78,12 @@ func (a TransferAuthorization) Accept(ctx context.Context, msg proto.Message) (a AllowList: allocation.AllowList, } - return authztypes.AcceptResponse{Accept: true, Delete: false, Updated: &TransferAuthorization{ + return authz.AcceptResponse{Accept: true, Delete: false, Updated: &TransferAuthorization{ Allocations: a.Allocations, }}, nil } - return authztypes.AcceptResponse{}, errorsmod.Wrapf(ibcerrors.ErrNotFound, "requested port and channel allocation does not exist") + return authz.AcceptResponse{}, errorsmod.Wrapf(ibcerrors.ErrNotFound, "requested port and channel allocation does not exist") } // ValidateBasic implements Authorization.ValidateBasic. diff --git a/modules/apps/transfer/types/transfer_authorization_test.go b/modules/apps/transfer/types/transfer_authorization_test.go index bccf1a988a4..49db8c1f578 100644 --- a/modules/apps/transfer/types/transfer_authorization_test.go +++ b/modules/apps/transfer/types/transfer_authorization_test.go @@ -4,7 +4,7 @@ import ( sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - authztypes "github.com/cosmos/cosmos-sdk/types/authz" + authz "github.com/cosmos/cosmos-sdk/x/authz" "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" ibctesting "github.com/cosmos/ibc-go/v7/testing" @@ -20,12 +20,12 @@ func (suite *TypesTestSuite) TestTransferAuthorizationAccept() { testCases := []struct { name string malleate func() - assertResult func(res authztypes.AcceptResponse, err error) + assertResult func(res authz.AcceptResponse, err error) }{ { "success", func() {}, - func(res authztypes.AcceptResponse, err error) { + func(res authz.AcceptResponse, err error) { suite.Require().NoError(err) suite.Require().True(res.Accept) @@ -38,7 +38,7 @@ func (suite *TypesTestSuite) TestTransferAuthorizationAccept() { func() { msgTransfer.Token = sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(50)) }, - func(res authztypes.AcceptResponse, err error) { + func(res authz.AcceptResponse, err error) { suite.Require().NoError(err) suite.Require().True(res.Accept) @@ -56,7 +56,7 @@ func (suite *TypesTestSuite) TestTransferAuthorizationAccept() { func() { transferAuthz.Allocations[0].AllowList = []string{} }, - func(res authztypes.AcceptResponse, err error) { + func(res authz.AcceptResponse, err error) { suite.Require().NoError(err) suite.Require().True(res.Accept) @@ -75,7 +75,7 @@ func (suite *TypesTestSuite) TestTransferAuthorizationAccept() { transferAuthz.Allocations = append(transferAuthz.Allocations, alloc) }, - func(res authztypes.AcceptResponse, err error) { + func(res authz.AcceptResponse, err error) { suite.Require().NoError(err) suite.Require().True(res.Accept) @@ -93,7 +93,7 @@ func (suite *TypesTestSuite) TestTransferAuthorizationAccept() { func() { transferAuthz.Allocations[0].SpendLimit = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, types.UnboundedSpendLimit())) }, - func(res authztypes.AcceptResponse, err error) { + func(res authz.AcceptResponse, err error) { suite.Require().NoError(err) suite.Require().True(res.Accept) @@ -112,7 +112,7 @@ func (suite *TypesTestSuite) TestTransferAuthorizationAccept() { ) msgTransfer.Token = sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(50)) }, - func(res authztypes.AcceptResponse, err error) { + func(res authz.AcceptResponse, err error) { suite.Require().NoError(err) updatedTransferAuthz, ok := res.Updated.(*types.TransferAuthorization) @@ -134,7 +134,7 @@ func (suite *TypesTestSuite) TestTransferAuthorizationAccept() { msgTransfer.SourcePort = ibctesting.MockPort msgTransfer.SourceChannel = "channel-9" }, - func(res authztypes.AcceptResponse, err error) { + func(res authz.AcceptResponse, err error) { suite.Require().Error(err) }, }, @@ -143,7 +143,7 @@ func (suite *TypesTestSuite) TestTransferAuthorizationAccept() { func() { msgTransfer.Token = sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1000)) }, - func(res authztypes.AcceptResponse, err error) { + func(res authz.AcceptResponse, err error) { suite.Require().Error(err) }, }, @@ -152,7 +152,7 @@ func (suite *TypesTestSuite) TestTransferAuthorizationAccept() { func() { msgTransfer.Receiver = suite.chainB.SenderAccount.GetAddress().String() }, - func(res authztypes.AcceptResponse, err error) { + func(res authz.AcceptResponse, err error) { suite.Require().Error(err) }, }, diff --git a/modules/capability/go.mod b/modules/capability/go.mod index c543991a17f..2219c269d12 100644 --- a/modules/capability/go.mod +++ b/modules/capability/go.mod @@ -192,4 +192,4 @@ replace github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.2021 replace github.com/cosmos/ibc-go/v7 => ../.. // replace with the main branch, contianing the apphash fix -replace github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230628150442-76ade5fa31a5 +replace github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.50.0-alpha.0.0.20230629143215-6172a1a0bf9b diff --git a/testing/chain.go b/testing/chain.go index 9fcdcf52eb4..b40bd3df97c 100644 --- a/testing/chain.go +++ b/testing/chain.go @@ -83,7 +83,7 @@ type TestChain struct { // Short-term solution to override the logic of the standard SendMsgs function. // See issue https://github.com/cosmos/ibc-go/issues/3123 for more information. - SendMsgsOverride func(msgs ...sdk.Msg) (*sdk.Result, error) + SendMsgsOverride func(msgs ...sdk.Msg) (*abci.ExecTxResult, error) } // NewTestChainWithValSet initializes a new TestChain instance with the given validator set @@ -294,8 +294,9 @@ func (chain *TestChain) QueryConsensusStateProof(clientID string) ([]byte, clien // It calls BeginBlock with the new block created before returning. func (chain *TestChain) NextBlock() { res, err := chain.App.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: chain.CurrentHeader.Height, - Time: chain.CurrentHeader.GetTime(), + Height: chain.CurrentHeader.Height, + Time: chain.CurrentHeader.GetTime(), + NextValidatorsHash: chain.NextVals.Hash(), }) require.NoError(chain.TB, err) chain.commitBlock(res) @@ -337,7 +338,7 @@ func (chain *TestChain) sendMsgs(msgs ...sdk.Msg) error { // SendMsgs delivers a transaction through the application. It updates the senders sequence // number and updates the TestChain's headers. It returns the result and error if one // occurred. -func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*sdk.Result, error) { +func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*abci.ExecTxResult, error) { if chain.SendMsgsOverride != nil { return chain.SendMsgsOverride(msgs...) } @@ -345,7 +346,7 @@ func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*sdk.Result, error) { // ensure the chain has the latest time chain.Coordinator.UpdateTimeForChain(chain) - _, r, resp, err := simapp.SignAndDeliver( + resp, err := simapp.SignAndDeliver( chain.TB, chain.TxConfig, chain.App.GetBaseApp(), @@ -355,6 +356,7 @@ func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*sdk.Result, error) { []uint64{chain.SenderAccount.GetSequence()}, true, chain.CurrentHeader.GetTime(), + chain.NextVals.Hash(), chain.SenderPrivKey, ) if err != nil { @@ -364,6 +366,13 @@ func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*sdk.Result, error) { // NextBlock calls app.Commit() chain.commitBlock(resp) + require.Len(chain.TB, resp.TxResults, 1) + txResult := resp.TxResults[0] + + if txResult.Code != 0 { + return txResult, fmt.Errorf("%s/%d: %q", txResult.Codespace, txResult.Code, txResult.Log) + } + // increment sequence for successful transaction execution err = chain.SenderAccount.SetSequence(chain.SenderAccount.GetSequence() + 1) if err != nil { @@ -372,7 +381,7 @@ func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*sdk.Result, error) { chain.Coordinator.IncrementTime() - return r, nil + return txResult, nil } // GetClientState retrieves the client state for the provided clientID. The client is diff --git a/testing/endpoint.go b/testing/endpoint.go index c938f99d5e6..b3b42fc0fae 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -7,7 +7,8 @@ import ( "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/baseapp" - sdk "github.com/cosmos/cosmos-sdk/types" + + abci "github.com/cometbft/cometbft/abci/types" clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" @@ -81,7 +82,7 @@ func (endpoint *Endpoint) QueryProofAtHeight(key []byte, height uint64) ([]byte, // NOTE: a solo machine client will be created with an empty diversifier. func (endpoint *Endpoint) CreateClient() (err error) { // ensure counterparty has committed state - endpoint.Chain.Coordinator.CommitBlock(endpoint.Counterparty.Chain) + endpoint.Counterparty.Chain.NextBlock() var ( clientState exported.ClientState @@ -461,7 +462,7 @@ func (endpoint *Endpoint) RecvPacket(packet channeltypes.Packet) error { // RecvPacketWithResult receives a packet on the associated endpoint and the result // of the transaction is returned. The counterparty client is updated. -func (endpoint *Endpoint) RecvPacketWithResult(packet channeltypes.Packet) (*sdk.Result, error) { +func (endpoint *Endpoint) RecvPacketWithResult(packet channeltypes.Packet) (*abci.ExecTxResult, error) { // get proof of packet commitment on source packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) proof, proofHeight := endpoint.Counterparty.Chain.QueryProof(packetKey) diff --git a/testing/events.go b/testing/events.go index 224f4b73e84..76b60161e5d 100644 --- a/testing/events.go +++ b/testing/events.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/suite" - sdk "github.com/cosmos/cosmos-sdk/types" + abci "github.com/cometbft/cometbft/abci/types" clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" @@ -17,7 +17,7 @@ type EventsMap map[string]map[string]string // ParseClientIDFromEvents parses events emitted from a MsgCreateClient and returns the // client identifier. -func ParseClientIDFromEvents(events sdk.Events) (string, error) { +func ParseClientIDFromEvents(events []abci.Event) (string, error) { for _, ev := range events { if ev.Type == clienttypes.EventTypeCreateClient { for _, attr := range ev.Attributes { @@ -32,7 +32,7 @@ func ParseClientIDFromEvents(events sdk.Events) (string, error) { // ParseConnectionIDFromEvents parses events emitted from a MsgConnectionOpenInit or // MsgConnectionOpenTry and returns the connection identifier. -func ParseConnectionIDFromEvents(events sdk.Events) (string, error) { +func ParseConnectionIDFromEvents(events []abci.Event) (string, error) { for _, ev := range events { if ev.Type == connectiontypes.EventTypeConnectionOpenInit || ev.Type == connectiontypes.EventTypeConnectionOpenTry { @@ -48,7 +48,7 @@ func ParseConnectionIDFromEvents(events sdk.Events) (string, error) { // ParseChannelIDFromEvents parses events emitted from a MsgChannelOpenInit or // MsgChannelOpenTry and returns the channel identifier. -func ParseChannelIDFromEvents(events sdk.Events) (string, error) { +func ParseChannelIDFromEvents(events []abci.Event) (string, error) { for _, ev := range events { if ev.Type == channeltypes.EventTypeChannelOpenInit || ev.Type == channeltypes.EventTypeChannelOpenTry { for _, attr := range ev.Attributes { @@ -63,7 +63,7 @@ func ParseChannelIDFromEvents(events sdk.Events) (string, error) { // ParsePacketFromEvents parses events emitted from a MsgRecvPacket and returns the // acknowledgement. -func ParsePacketFromEvents(events sdk.Events) (channeltypes.Packet, error) { +func ParsePacketFromEvents(events []abci.Event) (channeltypes.Packet, error) { for _, ev := range events { if ev.Type == channeltypes.EventTypeSendPacket { packet := channeltypes.Packet{} @@ -121,7 +121,7 @@ func ParsePacketFromEvents(events sdk.Events) (channeltypes.Packet, error) { // ParseAckFromEvents parses events emitted from a MsgRecvPacket and returns the // acknowledgement. -func ParseAckFromEvents(events sdk.Events) ([]byte, error) { +func ParseAckFromEvents(events []abci.Event) ([]byte, error) { for _, ev := range events { if ev.Type == channeltypes.EventTypeWriteAck { for _, attr := range ev.Attributes { @@ -139,7 +139,7 @@ func ParseAckFromEvents(events sdk.Events) ([]byte, error) { func AssertEvents( suite *suite.Suite, expected EventsMap, - actual sdk.Events, + actual []abci.Event, ) { hasEvents := make(map[string]bool) for eventType := range expected { diff --git a/testing/simapp/export.go b/testing/simapp/export.go index 0f81d0a0c57..0882afca67f 100644 --- a/testing/simapp/export.go +++ b/testing/simapp/export.go @@ -102,10 +102,7 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [] app.DistrKeeper.DeleteAllValidatorSlashEvents(ctx) // clear validator historical rewards - err = app.DistrKeeper.ValidatorHistoricalRewards.Clear(ctx, nil) - if err != nil { - panic(err) - } + app.DistrKeeper.DeleteAllValidatorHistoricalRewards(ctx) // set context height to zero height := ctx.BlockHeight() diff --git a/testing/simapp/test_helpers.go b/testing/simapp/test_helpers.go index 8e84457d2ba..825ea5c72aa 100644 --- a/testing/simapp/test_helpers.go +++ b/testing/simapp/test_helpers.go @@ -11,7 +11,6 @@ import ( dbm "github.com/cosmos/cosmos-db" "github.com/stretchr/testify/require" - "cosmossdk.io/errors" "cosmossdk.io/log" sdkmath "cosmossdk.io/math" pruningtypes "cosmossdk.io/store/pruning/types" @@ -261,8 +260,8 @@ func NewTestNetworkFixture() network.TestFixture { // CONTRACT: BeginBlock must be called before this function. func SignAndDeliver( tb testing.TB, txCfg client.TxConfig, app *bam.BaseApp, msgs []sdk.Msg, - chainID string, accNums, accSeqs []uint64, expPass bool, blockTime time.Time, priv ...cryptotypes.PrivKey, -) (sdk.GasInfo, *sdk.Result, *abci.ResponseFinalizeBlock, error) { + chainID string, accNums, accSeqs []uint64, expPass bool, blockTime time.Time, nextValHash []byte, priv ...cryptotypes.PrivKey, +) (*abci.ResponseFinalizeBlock, error) { tb.Helper() tx, err := simtestutil.GenSignedMockTx( rand.New(rand.NewSource(time.Now().UnixNano())), @@ -276,43 +275,14 @@ func SignAndDeliver( priv..., ) require.NoError(tb, err) + txBytes, err := txCfg.TxEncoder()(tx) require.NoError(tb, err) - // Must simulate now as CheckTx doesn't run Msgs anymore - _, res, err := app.Simulate(txBytes) - - if expPass { - require.NoError(tb, err) - require.NotNil(tb, res) - } else { - require.Error(tb, err) - require.Nil(tb, res) - } - - resBlock, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: app.LastBlockHeight() + 1, - Time: blockTime, - Txs: [][]byte{txBytes}, + return app.FinalizeBlock(&abci.RequestFinalizeBlock{ + Height: app.LastBlockHeight() + 1, + Time: blockTime, + NextValidatorsHash: nextValHash, + Txs: [][]byte{txBytes}, }) - require.NoError(tb, err) - - require.Equal(tb, 1, len(resBlock.TxResults)) - txResult := resBlock.TxResults[0] - finalizeSuccess := txResult.Code == 0 - if expPass { - require.True(tb, finalizeSuccess) - } else { - require.False(tb, finalizeSuccess) - } - - gInfo := sdk.GasInfo{GasWanted: uint64(txResult.GasWanted), GasUsed: uint64(txResult.GasUsed)} - txRes := sdk.Result{Data: txResult.Data, Log: txResult.Log, Events: txResult.Events} - if finalizeSuccess { - err = nil - } else { - err = errors.ABCIError(txResult.Codespace, txResult.Code, txResult.Log) - } - - return gInfo, &txRes, resBlock, err } diff --git a/testing/solomachine.go b/testing/solomachine.go index df683d3ea0c..8ec38568861 100644 --- a/testing/solomachine.go +++ b/testing/solomachine.go @@ -323,9 +323,10 @@ func (solo *Solomachine) ChanOpenInit(chain *TestChain, connectionID string) str require.NoError(solo.t, err) require.NotNil(solo.t, res) - if res, ok := res.MsgResponses[0].GetCachedValue().(*channeltypes.MsgChannelOpenInitResponse); ok { - return res.ChannelId - } + // TODO: unmarshal ExecTxResult data into msg responses + // if res, ok := res.MsgResponses[0].GetCachedValue().(*channeltypes.MsgChannelOpenInitResponse); ok { + // return res.ChannelId + // } return "" } From 21b78b19ab8300eadb5d38952909e9dec367c362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Thu, 29 Jun 2023 18:19:30 +0200 Subject: [PATCH 2/2] go mod tidy in capability --- modules/capability/go.mod | 2 +- modules/capability/go.sum | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/capability/go.mod b/modules/capability/go.mod index 2219c269d12..8b641216edf 100644 --- a/modules/capability/go.mod +++ b/modules/capability/go.mod @@ -3,7 +3,7 @@ module github.com/cosmos/ibc-go/modules/capability go 1.20 require ( - cosmossdk.io/core v0.8.0 + cosmossdk.io/core v0.9.0 cosmossdk.io/errors v1.0.0-beta.7.0.20230524212735-6cabb6aa5741 cosmossdk.io/log v1.1.0 cosmossdk.io/math v1.0.1 diff --git a/modules/capability/go.sum b/modules/capability/go.sum index 2526f98da5c..141ebd64cf9 100644 --- a/modules/capability/go.sum +++ b/modules/capability/go.sum @@ -194,8 +194,8 @@ cosmossdk.io/client/v2 v2.0.0-20230615173548-5385116abac4 h1:hRgwSTe49l1S+nA4l4A cosmossdk.io/client/v2 v2.0.0-20230615173548-5385116abac4/go.mod h1:0LYJm2+vdRIRDSP4yZZMGn68z6ZAFyLC0kuK31zXsOk= cosmossdk.io/collections v0.2.1-0.20230620134406-d4f1e88b6531 h1:6CxleI/IgdENrujwTY2yY9Wg52DVZr4eq4L71ANoLuQ= cosmossdk.io/collections v0.2.1-0.20230620134406-d4f1e88b6531/go.mod h1:k8IKBKC/lO+BKoIGae3RC8NCBV8+7JaAw+es51YylFs= -cosmossdk.io/core v0.8.0 h1:LcJnu52E1a8f8E317VfQ1xK/RZe+IuhMNQAjnDLh25M= -cosmossdk.io/core v0.8.0/go.mod h1:LF6VLOv2DdCiaHxYVmr0MZcZpaSM9ZgvyrQSYTeg6D0= +cosmossdk.io/core v0.9.0 h1:30ScAOHDIUOCg1DKAwqkho9wuQJnu7GUrMcg0XLioic= +cosmossdk.io/core v0.9.0/go.mod h1:NFgl5r41Q36+RixTvyrfsS6qQ65agCbZ1FTpnN7/G1Y= cosmossdk.io/depinject v1.0.0-alpha.3 h1:6evFIgj//Y3w09bqOUOzEpFj5tsxBqdc5CfkO7z+zfw= cosmossdk.io/depinject v1.0.0-alpha.3/go.mod h1:eRbcdQ7MRpIPEM5YUJh8k97nxHpYbc3sMUnEtt8HPWU= cosmossdk.io/errors v1.0.0-beta.7.0.20230524212735-6cabb6aa5741 h1:BCRz06fvddw7cKGiEGDiSox3qMsjQ97f92K+PDZDHdc= @@ -345,8 +345,8 @@ github.com/cosmos/cosmos-db v1.0.0 h1:EVcQZ+qYag7W6uorBKFPvX6gRjw6Uq2hIh4hCWjuQ0 github.com/cosmos/cosmos-db v1.0.0/go.mod h1:iBvi1TtqaedwLdcrZVYRSSCb6eSy61NLj4UNmdIgs0U= github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= -github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230628150442-76ade5fa31a5 h1:NMcL4LKDvu51yiAZBbjCZGTH/M+MfUkq4Jld4QyNsSw= -github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230628150442-76ade5fa31a5/go.mod h1:6bhpmPC0p3AgJC4jNKImoSFcQSG1xlq8QgL2Uc4yc4U= +github.com/cosmos/cosmos-sdk v0.50.0-alpha.0.0.20230629143215-6172a1a0bf9b h1:7U9laUmlfVKEUwcFC2mDhfdyC3Ygxm4GlJEFAhrH41c= +github.com/cosmos/cosmos-sdk v0.50.0-alpha.0.0.20230629143215-6172a1a0bf9b/go.mod h1:10q0oPIC2/RZEWlGesvLsQtQDXEPnh2bF1rRf/mwAEk= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE=