From 7b7a72a161cc47ac3fed4d221385f8884c8d2493 Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Wed, 10 Apr 2024 14:47:43 +0200 Subject: [PATCH] more changes --- baseapp/abci.go | 114 +++--- baseapp/abci_test.go | 380 +++++++++--------- baseapp/abci_utils.go | 30 +- baseapp/abci_utils_test.go | 22 +- baseapp/baseapp_test.go | 56 +-- baseapp/grpcrouter_helpers.go | 2 +- baseapp/oe/optimistic_execution_test.go | 4 +- baseapp/snapshot_test.go | 58 +-- baseapp/streaming_test.go | 14 +- ...r-040-storage-and-smt-state-commitments.md | 6 +- docs/architecture/adr-060-abci-1.0.md | 2 +- docs/architecture/adr-064-abci-2.0.md | 6 +- docs/architecture/adr-067-simulator-v2.md | 4 +- docs/build/abci/03-vote-extensions.md | 2 +- .../building-modules/01-module-manager.md | 2 +- .../02-messages-and-queries.md | 2 +- docs/learn/advanced/00-baseapp.md | 10 +- docs/learn/advanced/15-upgrade.md | 2 +- docs/learn/beginner/01-tx-lifecycle.md | 2 +- docs/learn/beginner/02-query-lifecycle.md | 2 +- docs/spec/store/README.md | 2 +- server/cmt_abci.go | 2 +- server/mock/app.go | 8 +- server/mock/app_test.go | 4 +- server/types/abci.go | 28 +- simapp/abci.go | 4 +- simapp/app.go | 2 +- simapp/app_di.go | 2 +- .../integration/auth/client/cli/suite_test.go | 2 +- tests/integration/distribution/cli_tx_test.go | 2 +- testutil/cli/cmt_mocks.go | 4 +- types/abci.go | 14 +- types/errors/abci.go | 8 +- types/module/module.go | 16 +- x/auth/ante/testutil_test.go | 2 +- x/authz/client/cli/tx_test.go | 2 +- x/feegrant/client/cli/tx_test.go | 2 +- x/genutil/client/cli/gentx_test.go | 2 +- x/gov/client/cli/tx_test.go | 2 +- x/group/client/cli/tx_test.go | 2 +- x/simulation/mock_cometbft.go | 10 +- x/simulation/simulate.go | 2 +- x/staking/client/cli/tx_test.go | 2 +- x/staking/types/validator.go | 1 - 44 files changed, 422 insertions(+), 423 deletions(-) diff --git a/baseapp/abci.go b/baseapp/abci.go index 37e3d0b87466..f5841ed3ec49 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -37,7 +37,7 @@ const ( QueryPathBroadcastTx = "/cosmos.tx.v1beta1.Service/BroadcastTx" ) -func (app *BaseApp) InitChain(req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { +func (app *BaseApp) InitChain(req *abci.InitChainRequest) (*abci.InitChainResponse, error) { if req.ChainId != app.chainID { return nil, fmt.Errorf("invalid chain-id on InitChain; expected: %s, got: %s", app.chainID, req.ChainId) } @@ -97,7 +97,7 @@ func (app *BaseApp) InitChain(req *abci.RequestInitChain) (*abci.ResponseInitCha }() if app.initChainer == nil { - return &abci.ResponseInitChain{}, nil + return &abci.InitChainResponse{}, nil } // add block gas meter for any genesis transactions (allow infinite gas) @@ -128,14 +128,14 @@ func (app *BaseApp) InitChain(req *abci.RequestInitChain) (*abci.ResponseInitCha // NOTE: We don't commit, but FinalizeBlock for block InitialHeight starts from // this FinalizeBlockState. - return &abci.ResponseInitChain{ + return &abci.InitChainResponse{ ConsensusParams: res.ConsensusParams, Validators: res.Validators, AppHash: app.LastCommitID().Hash, }, nil } -func (app *BaseApp) Info(_ *abci.RequestInfo) (*abci.ResponseInfo, error) { +func (app *BaseApp) Info(_ *abci.InfoRequest) (*abci.InfoResponse, error) { lastCommitID := app.cms.LastCommitID() appVersion := InitialAppVersion if lastCommitID.Version > 0 { @@ -149,7 +149,7 @@ func (app *BaseApp) Info(_ *abci.RequestInfo) (*abci.ResponseInfo, error) { } } - return &abci.ResponseInfo{ + return &abci.InfoResponse{ Data: app.name, Version: app.version, AppVersion: appVersion, @@ -160,7 +160,7 @@ func (app *BaseApp) Info(_ *abci.RequestInfo) (*abci.ResponseInfo, error) { // Query implements the ABCI interface. It delegates to CommitMultiStore if it // implements Queryable. -func (app *BaseApp) Query(_ context.Context, req *abci.RequestQuery) (resp *abci.ResponseQuery, err error) { +func (app *BaseApp) Query(_ context.Context, req *abci.QueryRequest) (resp *abci.QueryResponse, err error) { // add panic recovery for all queries // // Ref: https://github.com/cosmos/cosmos-sdk/pull/8039 @@ -213,8 +213,8 @@ func (app *BaseApp) Query(_ context.Context, req *abci.RequestQuery) (resp *abci } // ListSnapshots implements the ABCI interface. It delegates to app.snapshotManager if set. -func (app *BaseApp) ListSnapshots(req *abci.RequestListSnapshots) (*abci.ResponseListSnapshots, error) { - resp := &abci.ResponseListSnapshots{Snapshots: []*abci.Snapshot{}} +func (app *BaseApp) ListSnapshots(req *abci.ListSnapshotsRequest) (*abci.ListSnapshotsResponse, error) { + resp := &abci.ListSnapshotsResponse{Snapshots: []*abci.Snapshot{}} if app.snapshotManager == nil { return resp, nil } @@ -239,9 +239,9 @@ func (app *BaseApp) ListSnapshots(req *abci.RequestListSnapshots) (*abci.Respons } // LoadSnapshotChunk implements the ABCI interface. It delegates to app.snapshotManager if set. -func (app *BaseApp) LoadSnapshotChunk(req *abci.RequestLoadSnapshotChunk) (*abci.ResponseLoadSnapshotChunk, error) { +func (app *BaseApp) LoadSnapshotChunk(req *abci.LoadSnapshotChunkRequest) (*abci.LoadSnapshotChunkResponse, error) { if app.snapshotManager == nil { - return &abci.ResponseLoadSnapshotChunk{}, nil + return &abci.LoadSnapshotChunkResponse{}, nil } chunk, err := app.snapshotManager.LoadChunk(req.Height, req.Format, req.Chunk) @@ -256,34 +256,34 @@ func (app *BaseApp) LoadSnapshotChunk(req *abci.RequestLoadSnapshotChunk) (*abci return nil, err } - return &abci.ResponseLoadSnapshotChunk{Chunk: chunk}, nil + return &abci.LoadSnapshotChunkResponse{Chunk: chunk}, nil } // OfferSnapshot implements the ABCI interface. It delegates to app.snapshotManager if set. -func (app *BaseApp) OfferSnapshot(req *abci.RequestOfferSnapshot) (*abci.ResponseOfferSnapshot, error) { +func (app *BaseApp) OfferSnapshot(req *abci.OfferSnapshotRequest) (*abci.OfferSnapshotResponse, error) { if app.snapshotManager == nil { app.logger.Error("snapshot manager not configured") - return &abci.ResponseOfferSnapshot{Result: abci.ResponseOfferSnapshot_ABORT}, nil + return &abci.OfferSnapshotResponse{Result: abci.OFFER_SNAPSHOT_RESULT_ABORT}, nil } if req.Snapshot == nil { app.logger.Error("received nil snapshot") - return &abci.ResponseOfferSnapshot{Result: abci.ResponseOfferSnapshot_REJECT}, nil + return &abci.OfferSnapshotResponse{Result: abci.OFFER_SNAPSHOT_RESULT_REJECT}, nil } snapshot, err := snapshottypes.SnapshotFromABCI(req.Snapshot) if err != nil { app.logger.Error("failed to decode snapshot metadata", "err", err) - return &abci.ResponseOfferSnapshot{Result: abci.ResponseOfferSnapshot_REJECT}, nil + return &abci.OfferSnapshotResponse{Result: abci.OFFER_SNAPSHOT_RESULT_REJECT}, nil } err = app.snapshotManager.Restore(snapshot) switch { case err == nil: - return &abci.ResponseOfferSnapshot{Result: abci.ResponseOfferSnapshot_ACCEPT}, nil + return &abci.OfferSnapshotResponse{Result: abci.OFFER_SNAPSHOT_RESULT_ACCEPT}, nil case errors.Is(err, snapshottypes.ErrUnknownFormat): - return &abci.ResponseOfferSnapshot{Result: abci.ResponseOfferSnapshot_REJECT_FORMAT}, nil + return &abci.OfferSnapshotResponse{Result: abci.OFFER_SNAPSHOT_RESULT_REJECT_FORMAT}, nil case errors.Is(err, snapshottypes.ErrInvalidMetadata): app.logger.Error( @@ -292,7 +292,7 @@ func (app *BaseApp) OfferSnapshot(req *abci.RequestOfferSnapshot) (*abci.Respons "format", req.Snapshot.Format, "err", err, ) - return &abci.ResponseOfferSnapshot{Result: abci.ResponseOfferSnapshot_REJECT}, nil + return &abci.OfferSnapshotResponse{Result: abci.OFFER_SNAPSHOT_RESULT_REJECT}, nil default: app.logger.Error( @@ -304,21 +304,21 @@ func (app *BaseApp) OfferSnapshot(req *abci.RequestOfferSnapshot) (*abci.Respons // We currently don't support resetting the IAVL stores and retrying a // different snapshot, so we ask CometBFT to abort all snapshot restoration. - return &abci.ResponseOfferSnapshot{Result: abci.ResponseOfferSnapshot_ABORT}, nil + return &abci.OfferSnapshotResponse{Result: abci.OFFER_SNAPSHOT_RESULT_ABORT}, nil } } // ApplySnapshotChunk implements the ABCI interface. It delegates to app.snapshotManager if set. -func (app *BaseApp) ApplySnapshotChunk(req *abci.RequestApplySnapshotChunk) (*abci.ResponseApplySnapshotChunk, error) { +func (app *BaseApp) ApplySnapshotChunk(req *abci.ApplySnapshotChunkRequest) (*abci.ApplySnapshotChunkResponse, error) { if app.snapshotManager == nil { app.logger.Error("snapshot manager not configured") - return &abci.ResponseApplySnapshotChunk{Result: abci.ResponseApplySnapshotChunk_ABORT}, nil + return &abci.ApplySnapshotChunkResponse{Result: abci.APPLY_SNAPSHOT_CHUNK_RESULT_ABORT}, nil } _, err := app.snapshotManager.RestoreChunk(req.Chunk) switch { case err == nil: - return &abci.ResponseApplySnapshotChunk{Result: abci.ResponseApplySnapshotChunk_ACCEPT}, nil + return &abci.ApplySnapshotChunkResponse{Result: abci.APPLY_SNAPSHOT_CHUNK_RESULT_ACCEPT}, nil case errors.Is(err, snapshottypes.ErrChunkHashMismatch): app.logger.Error( @@ -327,15 +327,15 @@ func (app *BaseApp) ApplySnapshotChunk(req *abci.RequestApplySnapshotChunk) (*ab "sender", req.Sender, "err", err, ) - return &abci.ResponseApplySnapshotChunk{ - Result: abci.ResponseApplySnapshotChunk_RETRY, + return &abci.ApplySnapshotChunkResponse{ + Result: abci.APPLY_SNAPSHOT_CHUNK_RESULT_RETRY, RefetchChunks: []uint32{req.Index}, RejectSenders: []string{req.Sender}, }, nil default: app.logger.Error("failed to restore snapshot", "err", err) - return &abci.ResponseApplySnapshotChunk{Result: abci.ResponseApplySnapshotChunk_ABORT}, nil + return &abci.ApplySnapshotChunkResponse{Result: abci.APPLY_SNAPSHOT_CHUNK_RESULT_ABORT}, nil } } @@ -345,14 +345,14 @@ func (app *BaseApp) ApplySnapshotChunk(req *abci.RequestApplySnapshotChunk) (*ab // internal CheckTx state if the AnteHandler passes. Otherwise, the ResponseCheckTx // will contain relevant error information. Regardless of tx execution outcome, // the ResponseCheckTx will contain relevant gas execution context. -func (app *BaseApp) CheckTx(req *abci.RequestCheckTx) (*abci.ResponseCheckTx, error) { +func (app *BaseApp) CheckTx(req *abci.CheckTxRequest) (*abci.CheckTxResponse, error) { var mode execMode switch { - case req.Type == abci.CheckTxType_New: + case req.Type == abci.CHECK_TX_TYPE_CHECK: mode = execModeCheck - case req.Type == abci.CheckTxType_Recheck: + case req.Type == abci.CHECK_TX_TYPE_RECHECK: mode = execModeReCheck default: @@ -364,7 +364,7 @@ func (app *BaseApp) CheckTx(req *abci.RequestCheckTx) (*abci.ResponseCheckTx, er return sdkerrors.ResponseCheckTxWithEvents(err, gInfo.GasWanted, gInfo.GasUsed, anteEvents, app.trace), nil } - return &abci.ResponseCheckTx{ + return &abci.CheckTxResponse{ GasWanted: int64(gInfo.GasWanted), // TODO: Should type accept unsigned ints? GasUsed: int64(gInfo.GasUsed), // TODO: Should type accept unsigned ints? Log: result.Log, @@ -386,7 +386,7 @@ func (app *BaseApp) CheckTx(req *abci.RequestCheckTx) (*abci.ResponseCheckTx, er // // Ref: https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-060-abci-1.0.md // Ref: https://github.com/cometbft/cometbft/blob/main/spec/abci/abci%2B%2B_basic_concepts.md -func (app *BaseApp) PrepareProposal(req *abci.RequestPrepareProposal) (resp *abci.ResponsePrepareProposal, err error) { +func (app *BaseApp) PrepareProposal(req *abci.PrepareProposalRequest) (resp *abci.PrepareProposalResponse, err error) { if app.prepareProposal == nil { return nil, errors.New("PrepareProposal handler not set") } @@ -440,14 +440,14 @@ func (app *BaseApp) PrepareProposal(req *abci.RequestPrepareProposal) (resp *abc "panic", err, ) - resp = &abci.ResponsePrepareProposal{Txs: req.Txs} + resp = &abci.PrepareProposalResponse{Txs: req.Txs} } }() resp, err = app.prepareProposal(app.prepareProposalState.Context(), req) if err != nil { app.logger.Error("failed to prepare proposal", "height", req.Height, "time", req.Time, "err", err) - return &abci.ResponsePrepareProposal{Txs: req.Txs}, nil + return &abci.PrepareProposalResponse{Txs: req.Txs}, nil } return resp, nil @@ -468,7 +468,7 @@ func (app *BaseApp) PrepareProposal(req *abci.RequestPrepareProposal) (resp *abc // // Ref: https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-060-abci-1.0.md // Ref: https://github.com/cometbft/cometbft/blob/main/spec/abci/abci%2B%2B_basic_concepts.md -func (app *BaseApp) ProcessProposal(req *abci.RequestProcessProposal) (resp *abci.ResponseProcessProposal, err error) { +func (app *BaseApp) ProcessProposal(req *abci.ProcessProposalRequest) (resp *abci.ProcessProposalResponse, err error) { if app.processProposal == nil { return nil, errors.New("ProcessProposal handler not set") } @@ -534,14 +534,14 @@ func (app *BaseApp) ProcessProposal(req *abci.RequestProcessProposal) (resp *abc "hash", fmt.Sprintf("%X", req.Hash), "panic", err, ) - resp = &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_REJECT} + resp = &abci.ProcessProposalResponse{Status: abci.PROCESS_PROPOSAL_STATUS_REJECT} } }() resp, err = app.processProposal(app.processProposalState.Context(), req) if err != nil { app.logger.Error("failed to process proposal", "height", req.Height, "time", req.Time, "hash", fmt.Sprintf("%X", req.Hash), "err", err) - return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_REJECT}, nil + return &abci.ProcessProposalResponse{Status: abci.PROCESS_PROPOSAL_STATUS_REJECT}, nil } // Only execute optimistic execution if the proposal is accepted, OE is @@ -551,7 +551,7 @@ func (app *BaseApp) ProcessProposal(req *abci.RequestProcessProposal) (resp *abc // After the first block has been processed, the next blocks will get executed // optimistically, so that when the ABCI client calls `FinalizeBlock` the app // can have a response ready. - if resp.Status == abci.ResponseProcessProposal_ACCEPT && + if resp.Status == abci.PROCESS_PROPOSAL_STATUS_ACCEPT && app.optimisticExec.Enabled() && req.Height > app.initialHeight { app.optimisticExec.Execute(req) @@ -569,7 +569,7 @@ func (app *BaseApp) ProcessProposal(req *abci.RequestProcessProposal) (resp *abc // Agreed upon vote extensions are made available to the proposer of the next // height and are committed in the subsequent height, i.e. H+2. An error is // returned if vote extensions are not enabled or if extendVote fails or panics. -func (app *BaseApp) ExtendVote(_ context.Context, req *abci.RequestExtendVote) (resp *abci.ResponseExtendVote, err error) { +func (app *BaseApp) ExtendVote(_ context.Context, req *abci.ExtendVoteRequest) (resp *abci.ExtendVoteResponse, err error) { // Always reset state given that ExtendVote and VerifyVoteExtension can timeout // and be called again in a subsequent round. var ctx sdk.Context @@ -629,7 +629,7 @@ func (app *BaseApp) ExtendVote(_ context.Context, req *abci.RequestExtendVote) ( resp, err = app.extendVote(ctx, req) if err != nil { app.logger.Error("failed to extend vote", "height", req.Height, "hash", fmt.Sprintf("%X", req.Hash), "err", err) - return &abci.ResponseExtendVote{VoteExtension: []byte{}}, nil + return &abci.ExtendVoteResponse{VoteExtension: []byte{}}, nil } return resp, err @@ -643,7 +643,7 @@ func (app *BaseApp) ExtendVote(_ context.Context, req *abci.RequestExtendVote) ( // extensions are not enabled or if verifyVoteExt fails or panics. // We highly recommend a size validation due to performance degradation, // see more here https://docs.cometbft.com/v0.38/qa/cometbft-qa-38#vote-extensions-testbed -func (app *BaseApp) VerifyVoteExtension(req *abci.RequestVerifyVoteExtension) (resp *abci.ResponseVerifyVoteExtension, err error) { +func (app *BaseApp) VerifyVoteExtension(req *abci.VerifyVoteExtensionRequest) (resp *abci.VerifyVoteExtensionResponse, err error) { if app.verifyVoteExt == nil { return nil, errors.New("application VerifyVoteExtension handler not set") } @@ -700,7 +700,7 @@ func (app *BaseApp) VerifyVoteExtension(req *abci.RequestVerifyVoteExtension) (r resp, err = app.verifyVoteExt(ctx, req) if err != nil { app.logger.Error("failed to verify vote extension", "height", req.Height, "err", err) - return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + return &abci.VerifyVoteExtensionResponse{Status: abci.VERIFY_VOTE_EXTENSION_STATUS_REJECT}, nil } return resp, err @@ -710,7 +710,7 @@ func (app *BaseApp) VerifyVoteExtension(req *abci.RequestVerifyVoteExtension) (r // Execution flow or by the FinalizeBlock ABCI method. The context received is // only used to handle early cancellation, for anything related to state app.finalizeBlockState.Context() // must be used. -func (app *BaseApp) internalFinalizeBlock(ctx context.Context, req *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) { +func (app *BaseApp) internalFinalizeBlock(ctx context.Context, req *abci.FinalizeBlockRequest) (*abci.FinalizeBlockResponse, error) { var events []abci.Event if err := app.checkHalt(req.Height, req.Time); err != nil { @@ -853,7 +853,7 @@ func (app *BaseApp) internalFinalizeBlock(ctx context.Context, req *abci.Request events = append(events, endBlock.Events...) cp := app.GetConsensusParams(app.finalizeBlockState.Context()) - return &abci.ResponseFinalizeBlock{ + return &abci.FinalizeBlockResponse{ Events: events, TxResults: txResults, ValidatorUpdates: endBlock.ValidatorUpdates, @@ -871,7 +871,7 @@ func (app *BaseApp) internalFinalizeBlock(ctx context.Context, req *abci.Request // skipped. This is to support compatibility with proposers injecting vote // extensions into the proposal, which should not themselves be executed in cases // where they adhere to the sdk.Tx interface. -func (app *BaseApp) FinalizeBlock(req *abci.RequestFinalizeBlock) (res *abci.ResponseFinalizeBlock, err error) { +func (app *BaseApp) FinalizeBlock(req *abci.FinalizeBlockRequest) (res *abci.FinalizeBlockResponse, err error) { defer func() { // call the streaming service hooks with the FinalizeBlock messages for _, streamingListener := range app.streamingManager.ABCIListeners { @@ -935,7 +935,7 @@ func (app *BaseApp) checkHalt(height int64, time time.Time) error { // defined in config, Commit will execute a deferred function call to check // against that height and gracefully halt if it matches the latest committed // height. -func (app *BaseApp) Commit() (*abci.ResponseCommit, error) { +func (app *BaseApp) Commit() (*abci.CommitResponse, error) { header := app.finalizeBlockState.Context().BlockHeader() retainHeight := app.GetBlockRetentionHeight(header.Height) @@ -950,7 +950,7 @@ func (app *BaseApp) Commit() (*abci.ResponseCommit, error) { app.cms.Commit() - resp := &abci.ResponseCommit{ + resp := &abci.CommitResponse{ RetainHeight: retainHeight, } @@ -1003,7 +1003,7 @@ func (app *BaseApp) workingHash() []byte { return commitHash } -func handleQueryApp(app *BaseApp, path []string, req *abci.RequestQuery) *abci.ResponseQuery { +func handleQueryApp(app *BaseApp, path []string, req *abci.QueryRequest) *abci.QueryResponse { if len(path) >= 2 { switch path[1] { case "simulate": @@ -1024,14 +1024,14 @@ func handleQueryApp(app *BaseApp, path []string, req *abci.RequestQuery) *abci.R return sdkerrors.QueryResult(errorsmod.Wrap(err, "failed to JSON encode simulation response"), app.trace) } - return &abci.ResponseQuery{ + return &abci.QueryResponse{ Codespace: sdkerrors.RootCodespace, Height: req.Height, Value: bz, } case "version": - return &abci.ResponseQuery{ + return &abci.QueryResponse{ Codespace: sdkerrors.RootCodespace, Height: req.Height, Value: []byte(app.version), @@ -1049,7 +1049,7 @@ func handleQueryApp(app *BaseApp, path []string, req *abci.RequestQuery) *abci.R ), app.trace) } -func handleQueryStore(app *BaseApp, path []string, req abci.RequestQuery) *abci.ResponseQuery { +func handleQueryStore(app *BaseApp, path []string, req abci.QueryRequest) *abci.QueryResponse { // "/store" prefix for store queries queryable, ok := app.cms.(storetypes.Queryable) if !ok { @@ -1073,18 +1073,18 @@ func handleQueryStore(app *BaseApp, path []string, req abci.RequestQuery) *abci. } resp.Height = req.Height - abciResp := abci.ResponseQuery(*resp) + abciResp := abci.QueryResponse(*resp) return &abciResp } -func handleQueryP2P(app *BaseApp, path []string) *abci.ResponseQuery { +func handleQueryP2P(app *BaseApp, path []string) *abci.QueryResponse { // "/p2p" prefix for p2p queries if len(path) < 4 { return sdkerrors.QueryResult(errorsmod.Wrap(sdkerrors.ErrUnknownRequest, "path should be p2p filter "), app.trace) } - var resp *abci.ResponseQuery + var resp *abci.QueryResponse cmd, typ, arg := path[1], path[2], path[3] switch cmd { @@ -1119,21 +1119,21 @@ func SplitABCIQueryPath(requestPath string) (path []string) { } // FilterPeerByAddrPort filters peers by address/port. -func (app *BaseApp) FilterPeerByAddrPort(info string) *abci.ResponseQuery { +func (app *BaseApp) FilterPeerByAddrPort(info string) *abci.QueryResponse { if app.addrPeerFilter != nil { return app.addrPeerFilter(info) } - return &abci.ResponseQuery{} + return &abci.QueryResponse{} } // FilterPeerByID filters peers by node ID. -func (app *BaseApp) FilterPeerByID(info string) *abci.ResponseQuery { +func (app *BaseApp) FilterPeerByID(info string) *abci.QueryResponse { if app.idPeerFilter != nil { return app.idPeerFilter(info) } - return &abci.ResponseQuery{} + return &abci.QueryResponse{} } // getContextForProposal returns the correct Context for PrepareProposal and @@ -1151,7 +1151,7 @@ func (app *BaseApp) getContextForProposal(ctx sdk.Context, height int64) sdk.Con return ctx } -func (app *BaseApp) handleQueryGRPC(handler GRPCQueryHandler, req *abci.RequestQuery) *abci.ResponseQuery { +func (app *BaseApp) handleQueryGRPC(handler GRPCQueryHandler, req *abci.QueryRequest) *abci.QueryResponse { ctx, err := app.CreateQueryContext(req.Height, req.Prove) if err != nil { return sdkerrors.QueryResult(err, app.trace) diff --git a/baseapp/abci_test.go b/baseapp/abci_test.go index 6c195578e630..46d03080a7ca 100644 --- a/baseapp/abci_test.go +++ b/baseapp/abci_test.go @@ -56,7 +56,7 @@ func TestABCI_Info(t *testing.T) { err := suite.baseApp.StoreConsensusParams(ctx, cmttypes.DefaultConsensusParams().ToProto()) require.NoError(t, err) - reqInfo := abci.RequestInfo{} + reqInfo := abci.InfoRequest{} res, err := suite.baseApp.Info(&reqInfo) require.NoError(t, err) @@ -70,7 +70,7 @@ func TestABCI_Info(t *testing.T) { require.NoError(t, err) require.Equal(t, appVersion, res.AppVersion) - _, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) + _, err = suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1}) require.NoError(t, err) _, err = suite.baseApp.Commit() require.NoError(t, err) @@ -84,7 +84,7 @@ func TestABCI_First_block_Height(t *testing.T) { suite := NewBaseAppSuite(t, baseapp.SetChainID("test-chain-id")) app := suite.baseApp - _, err := app.InitChain(&abci.RequestInitChain{ + _, err := app.InitChain(&abci.InitChainRequest{ ChainId: "test-chain-id", ConsensusParams: &cmtproto.ConsensusParams{Block: &cmtproto.BlockParams{MaxGas: 5000000}}, InitialHeight: 1, @@ -110,23 +110,23 @@ func TestABCI_InitChain(t *testing.T) { // set a value in the store on init chain key, value := []byte("hello"), []byte("goodbye") - var initChainer sdk.InitChainer = func(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { + var initChainer sdk.InitChainer = func(ctx sdk.Context, req *abci.InitChainRequest) (*abci.InitChainResponse, error) { store := ctx.KVStore(capKey) store.Set(key, value) - return &abci.ResponseInitChain{}, nil + return &abci.InitChainResponse{}, nil } - query := abci.RequestQuery{ + query := abci.QueryRequest{ Path: "/store/main/key", Data: key, } // initChain is nil and chain ID is wrong - errors - _, err := app.InitChain(&abci.RequestInitChain{ChainId: "wrong-chain-id"}) + _, err := app.InitChain(&abci.InitChainRequest{ChainId: "wrong-chain-id"}) require.Error(t, err) // initChain is nil - nothing happens - _, err = app.InitChain(&abci.RequestInitChain{ChainId: "test-chain-id"}) + _, err = app.InitChain(&abci.InitChainRequest{ChainId: "test-chain-id"}) require.NoError(t, err) resQ, err := app.Query(context.TODO(), &query) require.NoError(t, err) @@ -140,7 +140,7 @@ func TestABCI_InitChain(t *testing.T) { require.Nil(t, err) require.Equal(t, int64(0), app.LastBlockHeight()) - initChainRes, err := app.InitChain(&abci.RequestInitChain{AppStateBytes: []byte("{}"), ChainId: "test-chain-id"}) // must have valid JSON genesis file, even if empty + initChainRes, err := app.InitChain(&abci.InitChainRequest{AppStateBytes: []byte("{}"), ChainId: "test-chain-id"}) // must have valid JSON genesis file, even if empty require.NoError(t, err) // The AppHash returned by a new chain is the sha256 hash of "". @@ -160,7 +160,7 @@ func TestABCI_InitChain(t *testing.T) { chainID = getCheckStateCtx(app).ChainID() require.Equal(t, "test-chain-id", chainID, "ChainID in checkState not set correctly in InitChain") - _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{ + _, err = app.FinalizeBlock(&abci.FinalizeBlockRequest{ Hash: initChainRes.AppHash, Height: 1, }) @@ -188,7 +188,7 @@ func TestABCI_InitChain(t *testing.T) { require.Equal(t, value, resQ.Value) // commit and ensure we can still query - _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1}) + _, err = app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: app.LastBlockHeight() + 1}) require.NoError(t, err) _, err = app.Commit() require.NoError(t, err) @@ -204,7 +204,7 @@ func TestABCI_InitChain_WithInitialHeight(t *testing.T) { app := baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil) _, err := app.InitChain( - &abci.RequestInitChain{ + &abci.InitChainRequest{ InitialHeight: 3, }, ) @@ -221,16 +221,16 @@ func TestABCI_FinalizeBlock_WithInitialHeight(t *testing.T) { app := baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil) _, err := app.InitChain( - &abci.RequestInitChain{ + &abci.InitChainRequest{ InitialHeight: 3, }, ) require.NoError(t, err) - _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 4}) + _, err = app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 4}) require.Error(t, err, "invalid height: 4; expected: 3") - _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 3}) + _, err = app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 3}) require.NoError(t, err) _, err = app.Commit() require.NoError(t, err) @@ -275,13 +275,13 @@ func TestABCI_FinalizeBlock_WithBeginAndEndBlocker(t *testing.T) { }) _, err := app.InitChain( - &abci.RequestInitChain{ + &abci.InitChainRequest{ InitialHeight: 1, }, ) require.NoError(t, err) - res, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) + res, err := app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1}) require.NoError(t, err) require.Len(t, res.Events, 2) @@ -309,24 +309,24 @@ func TestABCI_ExtendVote(t *testing.T) { db := dbm.NewMemDB() app := baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil) - app.SetExtendVoteHandler(func(ctx sdk.Context, req *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) { + app.SetExtendVoteHandler(func(ctx sdk.Context, req *abci.ExtendVoteRequest) (*abci.ExtendVoteResponse, error) { voteExt := fooStr + hex.EncodeToString(req.Hash) + strconv.FormatInt(req.Height, 10) - return &abci.ResponseExtendVote{VoteExtension: []byte(voteExt)}, nil + return &abci.ExtendVoteResponse{VoteExtension: []byte(voteExt)}, nil }) - app.SetVerifyVoteExtensionHandler(func(ctx sdk.Context, req *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) { + app.SetVerifyVoteExtensionHandler(func(ctx sdk.Context, req *abci.VerifyVoteExtensionRequest) (*abci.VerifyVoteExtensionResponse, error) { // do some kind of verification here expectedVoteExt := fooStr + hex.EncodeToString(req.Hash) + strconv.FormatInt(req.Height, 10) if !bytes.Equal(req.VoteExtension, []byte(expectedVoteExt)) { - return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + return &abci.VerifyVoteExtensionResponse{Status: abci.VERIFY_VOTE_EXTENSION_STATUS_REJECT}, nil } - return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_ACCEPT}, nil + return &abci.VerifyVoteExtensionResponse{Status: abci.VERIFY_VOTE_EXTENSION_STATUS_ACCEPT}, nil }) app.SetParamStore(¶mStore{db: dbm.NewMemDB()}) _, err := app.InitChain( - &abci.RequestInitChain{ + &abci.InitChainRequest{ InitialHeight: 1, ConsensusParams: &cmtproto.ConsensusParams{ Abci: &cmtproto.ABCIParams{ @@ -338,51 +338,51 @@ func TestABCI_ExtendVote(t *testing.T) { require.NoError(t, err) // Votes not enabled yet - _, err = app.ExtendVote(context.Background(), &abci.RequestExtendVote{Height: 123, Hash: []byte("thehash")}) + _, err = app.ExtendVote(context.Background(), &abci.ExtendVoteRequest{Height: 123, Hash: []byte("thehash")}) require.ErrorContains(t, err, "vote extensions are not enabled") // First vote on the first enabled height - res, err := app.ExtendVote(context.Background(), &abci.RequestExtendVote{Height: 200, Hash: []byte("thehash")}) + res, err := app.ExtendVote(context.Background(), &abci.ExtendVoteRequest{Height: 200, Hash: []byte("thehash")}) require.NoError(t, err) require.Len(t, res.VoteExtension, 20) - res, err = app.ExtendVote(context.Background(), &abci.RequestExtendVote{Height: 1000, Hash: []byte("thehash")}) + res, err = app.ExtendVote(context.Background(), &abci.ExtendVoteRequest{Height: 1000, Hash: []byte("thehash")}) require.NoError(t, err) require.Len(t, res.VoteExtension, 21) // Error during vote extension should return an empty vote extension and no error - app.SetExtendVoteHandler(func(ctx sdk.Context, req *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) { + app.SetExtendVoteHandler(func(ctx sdk.Context, req *abci.ExtendVoteRequest) (*abci.ExtendVoteResponse, error) { return nil, errors.New("some error") }) - res, err = app.ExtendVote(context.Background(), &abci.RequestExtendVote{Height: 1000, Hash: []byte("thehash")}) + res, err = app.ExtendVote(context.Background(), &abci.ExtendVoteRequest{Height: 1000, Hash: []byte("thehash")}) require.NoError(t, err) require.Len(t, res.VoteExtension, 0) // Verify Vote Extensions - _, err = app.VerifyVoteExtension(&abci.RequestVerifyVoteExtension{Height: 123, VoteExtension: []byte("1234567")}) + _, err = app.VerifyVoteExtension(&abci.VerifyVoteExtensionRequest{Height: 123, VoteExtension: []byte("1234567")}) require.ErrorContains(t, err, "vote extensions are not enabled") // First vote on the first enabled height - vres, err := app.VerifyVoteExtension(&abci.RequestVerifyVoteExtension{Height: 200, Hash: []byte("thehash"), VoteExtension: []byte("foo74686568617368200")}) + vres, err := app.VerifyVoteExtension(&abci.VerifyVoteExtensionRequest{Height: 200, Hash: []byte("thehash"), VoteExtension: []byte("foo74686568617368200")}) require.NoError(t, err) - require.Equal(t, abci.ResponseVerifyVoteExtension_ACCEPT, vres.Status) + require.Equal(t, abci.VERIFY_VOTE_EXTENSION_STATUS_ACCEPT, vres.Status) - vres, err = app.VerifyVoteExtension(&abci.RequestVerifyVoteExtension{Height: 1000, Hash: []byte("thehash"), VoteExtension: []byte("foo746865686173681000")}) + vres, err = app.VerifyVoteExtension(&abci.VerifyVoteExtensionRequest{Height: 1000, Hash: []byte("thehash"), VoteExtension: []byte("foo746865686173681000")}) require.NoError(t, err) - require.Equal(t, abci.ResponseVerifyVoteExtension_ACCEPT, vres.Status) + require.Equal(t, abci.VERIFY_VOTE_EXTENSION_STATUS_ACCEPT, vres.Status) // Reject because it's just some random bytes - vres, err = app.VerifyVoteExtension(&abci.RequestVerifyVoteExtension{Height: 201, Hash: []byte("thehash"), VoteExtension: []byte("12345678")}) + vres, err = app.VerifyVoteExtension(&abci.VerifyVoteExtensionRequest{Height: 201, Hash: []byte("thehash"), VoteExtension: []byte("12345678")}) require.NoError(t, err) - require.Equal(t, abci.ResponseVerifyVoteExtension_REJECT, vres.Status) + require.Equal(t, abci.VERIFY_VOTE_EXTENSION_STATUS_REJECT, vres.Status) // Reject because the verification failed (no error) - app.SetVerifyVoteExtensionHandler(func(ctx sdk.Context, req *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) { + app.SetVerifyVoteExtensionHandler(func(ctx sdk.Context, req *abci.VerifyVoteExtensionRequest) (*abci.VerifyVoteExtensionResponse, error) { return nil, errors.New("some error") }) - vres, err = app.VerifyVoteExtension(&abci.RequestVerifyVoteExtension{Height: 201, Hash: []byte("thehash"), VoteExtension: []byte("12345678")}) + vres, err = app.VerifyVoteExtension(&abci.VerifyVoteExtensionRequest{Height: 201, Hash: []byte("thehash"), VoteExtension: []byte("12345678")}) require.NoError(t, err) - require.Equal(t, abci.ResponseVerifyVoteExtension_REJECT, vres.Status) + require.Equal(t, abci.VERIFY_VOTE_EXTENSION_STATUS_REJECT, vres.Status) } // TestABCI_OnlyVerifyVoteExtension makes sure we can call VerifyVoteExtension @@ -392,19 +392,19 @@ func TestABCI_OnlyVerifyVoteExtension(t *testing.T) { db := dbm.NewMemDB() app := baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil) - app.SetVerifyVoteExtensionHandler(func(ctx sdk.Context, req *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) { + app.SetVerifyVoteExtensionHandler(func(ctx sdk.Context, req *abci.VerifyVoteExtensionRequest) (*abci.VerifyVoteExtensionResponse, error) { // do some kind of verification here expectedVoteExt := fooStr + hex.EncodeToString(req.Hash) + strconv.FormatInt(req.Height, 10) if !bytes.Equal(req.VoteExtension, []byte(expectedVoteExt)) { - return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + return &abci.VerifyVoteExtensionResponse{Status: abci.VERIFY_VOTE_EXTENSION_STATUS_REJECT}, nil } - return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_ACCEPT}, nil + return &abci.VerifyVoteExtensionResponse{Status: abci.VERIFY_VOTE_EXTENSION_STATUS_ACCEPT}, nil }) app.SetParamStore(¶mStore{db: dbm.NewMemDB()}) _, err := app.InitChain( - &abci.RequestInitChain{ + &abci.InitChainRequest{ InitialHeight: 1, ConsensusParams: &cmtproto.ConsensusParams{ Abci: &cmtproto.ABCIParams{ @@ -416,30 +416,30 @@ func TestABCI_OnlyVerifyVoteExtension(t *testing.T) { require.NoError(t, err) // Verify Vote Extensions - _, err = app.VerifyVoteExtension(&abci.RequestVerifyVoteExtension{Height: 123, VoteExtension: []byte("1234567")}) + _, err = app.VerifyVoteExtension(&abci.VerifyVoteExtensionRequest{Height: 123, VoteExtension: []byte("1234567")}) require.ErrorContains(t, err, "vote extensions are not enabled") // First vote on the first enabled height - vres, err := app.VerifyVoteExtension(&abci.RequestVerifyVoteExtension{Height: 200, Hash: []byte("thehash"), VoteExtension: []byte("foo74686568617368200")}) + vres, err := app.VerifyVoteExtension(&abci.VerifyVoteExtensionRequest{Height: 200, Hash: []byte("thehash"), VoteExtension: []byte("foo74686568617368200")}) require.NoError(t, err) - require.Equal(t, abci.ResponseVerifyVoteExtension_ACCEPT, vres.Status) + require.Equal(t, abci.VERIFY_VOTE_EXTENSION_STATUS_ACCEPT, vres.Status) - vres, err = app.VerifyVoteExtension(&abci.RequestVerifyVoteExtension{Height: 1000, Hash: []byte("thehash"), VoteExtension: []byte("foo746865686173681000")}) + vres, err = app.VerifyVoteExtension(&abci.VerifyVoteExtensionRequest{Height: 1000, Hash: []byte("thehash"), VoteExtension: []byte("foo746865686173681000")}) require.NoError(t, err) - require.Equal(t, abci.ResponseVerifyVoteExtension_ACCEPT, vres.Status) + require.Equal(t, abci.VERIFY_VOTE_EXTENSION_STATUS_ACCEPT, vres.Status) // Reject because it's just some random bytes - vres, err = app.VerifyVoteExtension(&abci.RequestVerifyVoteExtension{Height: 201, Hash: []byte("thehash"), VoteExtension: []byte("12345678")}) + vres, err = app.VerifyVoteExtension(&abci.VerifyVoteExtensionRequest{Height: 201, Hash: []byte("thehash"), VoteExtension: []byte("12345678")}) require.NoError(t, err) - require.Equal(t, abci.ResponseVerifyVoteExtension_REJECT, vres.Status) + require.Equal(t, abci.VERIFY_VOTE_EXTENSION_STATUS_REJECT, vres.Status) // Reject because the verification failed (no error) - app.SetVerifyVoteExtensionHandler(func(ctx sdk.Context, req *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) { + app.SetVerifyVoteExtensionHandler(func(ctx sdk.Context, req *abci.VerifyVoteExtensionRequest) (*abci.VerifyVoteExtensionResponse, error) { return nil, errors.New("some error") }) - vres, err = app.VerifyVoteExtension(&abci.RequestVerifyVoteExtension{Height: 201, Hash: []byte("thehash"), VoteExtension: []byte("12345678")}) + vres, err = app.VerifyVoteExtension(&abci.VerifyVoteExtensionRequest{Height: 201, Hash: []byte("thehash"), VoteExtension: []byte("12345678")}) require.NoError(t, err) - require.Equal(t, abci.ResponseVerifyVoteExtension_REJECT, vres.Status) + require.Equal(t, abci.VERIFY_VOTE_EXTENSION_STATUS_REJECT, vres.Status) } func TestABCI_GRPCQuery(t *testing.T) { @@ -452,7 +452,7 @@ func TestABCI_GRPCQuery(t *testing.T) { suite := NewBaseAppSuite(t, grpcQueryOpt) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{}, }) require.NoError(t, err) @@ -461,7 +461,7 @@ func TestABCI_GRPCQuery(t *testing.T) { reqBz, err := req.Marshal() require.NoError(t, err) - resQuery, err := suite.baseApp.Query(context.TODO(), &abci.RequestQuery{ + resQuery, err := suite.baseApp.Query(context.TODO(), &abci.QueryRequest{ Data: reqBz, Path: "/testpb.Query/SayHello", }) @@ -469,13 +469,13 @@ func TestABCI_GRPCQuery(t *testing.T) { require.Equal(t, sdkerrors.ErrInvalidHeight.ABCICode(), resQuery.Code, resQuery) require.Contains(t, resQuery.Log, "TestABCI_GRPCQuery is not ready; please wait for first block") - _, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: suite.baseApp.LastBlockHeight() + 1}) + _, err = suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{Height: suite.baseApp.LastBlockHeight() + 1}) require.NoError(t, err) _, err = suite.baseApp.Commit() require.NoError(t, err) - reqQuery := abci.RequestQuery{ + reqQuery := abci.QueryRequest{ Data: reqBz, Path: "/testpb.Query/SayHello", } @@ -491,29 +491,29 @@ func TestABCI_GRPCQuery(t *testing.T) { func TestABCI_P2PQuery(t *testing.T) { addrPeerFilterOpt := func(bapp *baseapp.BaseApp) { - bapp.SetAddrPeerFilter(func(addrport string) *abci.ResponseQuery { + bapp.SetAddrPeerFilter(func(addrport string) *abci.QueryResponse { require.Equal(t, "1.1.1.1:8000", addrport) - return &abci.ResponseQuery{Code: uint32(3)} + return &abci.QueryResponse{Code: uint32(3)} }) } idPeerFilterOpt := func(bapp *baseapp.BaseApp) { - bapp.SetIDPeerFilter(func(id string) *abci.ResponseQuery { + bapp.SetIDPeerFilter(func(id string) *abci.QueryResponse { require.Equal(t, "testid", id) - return &abci.ResponseQuery{Code: uint32(4)} + return &abci.QueryResponse{Code: uint32(4)} }) } suite := NewBaseAppSuite(t, addrPeerFilterOpt, idPeerFilterOpt) - addrQuery := abci.RequestQuery{ + addrQuery := abci.QueryRequest{ Path: "/p2p/filter/addr/1.1.1.1:8000", } res, err := suite.baseApp.Query(context.TODO(), &addrQuery) require.NoError(t, err) require.Equal(t, uint32(3), res.Code) - idQuery := abci.RequestQuery{ + idQuery := abci.QueryRequest{ Path: "/p2p/filter/id/testid", } res, err = suite.baseApp.Query(context.TODO(), &idQuery) @@ -534,7 +534,7 @@ func TestBaseApp_PrepareCheckState(t *testing.T) { app := baseapp.NewBaseApp(name, logger, db, nil) app.SetParamStore(¶mStore{db: dbm.NewMemDB()}) - _, err := app.InitChain(&abci.RequestInitChain{ + _, err := app.InitChain(&abci.InitChainRequest{ ConsensusParams: cp, }) require.NoError(t, err) @@ -563,7 +563,7 @@ func TestBaseApp_Precommit(t *testing.T) { app := baseapp.NewBaseApp(name, logger, db, nil) app.SetParamStore(¶mStore{db: dbm.NewMemDB()}) - _, err := app.InitChain(&abci.RequestInitChain{ + _, err := app.InitChain(&abci.InitChainRequest{ ConsensusParams: cp, }) require.NoError(t, err) @@ -590,7 +590,7 @@ func TestABCI_CheckTx(t *testing.T) { baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), CounterServerImpl{t, capKey1, counterKey}) nTxs := int64(5) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{}, }) require.NoError(t, err) @@ -600,7 +600,7 @@ func TestABCI_CheckTx(t *testing.T) { txBytes, err := suite.txConfig.TxEncoder()(tx) require.NoError(t, err) - r, err := suite.baseApp.CheckTx(&abci.RequestCheckTx{Tx: txBytes}) + r, err := suite.baseApp.CheckTx(&abci.CheckTxRequest{Tx: txBytes}) require.NoError(t, err) require.True(t, r.IsOK(), fmt.Sprintf("%v", r)) require.Empty(t, r.GetEvents()) @@ -613,7 +613,7 @@ func TestABCI_CheckTx(t *testing.T) { require.Equal(t, nTxs, storedCounter) // if a block is committed, CheckTx state should be reset - _, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ + _, err = suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{ Height: 1, Hash: []byte("hash"), }) @@ -635,7 +635,7 @@ func TestABCI_FinalizeBlock_DeliverTx(t *testing.T) { anteOpt := func(bapp *baseapp.BaseApp) { bapp.SetAnteHandler(anteHandlerTxTest(t, capKey1, anteKey)) } suite := NewBaseAppSuite(t, anteOpt) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{}, }) require.NoError(t, err) @@ -659,7 +659,7 @@ func TestABCI_FinalizeBlock_DeliverTx(t *testing.T) { txs = append(txs, txBytes) } - res, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ + res, err := suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{ Height: int64(blockN) + 1, Txs: txs, }) @@ -686,7 +686,7 @@ func TestABCI_FinalizeBlock_MultiMsg(t *testing.T) { anteOpt := func(bapp *baseapp.BaseApp) { bapp.SetAnteHandler(anteHandlerTxTest(t, capKey1, anteKey)) } suite := NewBaseAppSuite(t, anteOpt) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{}, }) require.NoError(t, err) @@ -703,7 +703,7 @@ func TestABCI_FinalizeBlock_MultiMsg(t *testing.T) { txBytes, err := suite.txConfig.TxEncoder()(tx) require.NoError(t, err) - _, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ + _, err = suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{ Height: 1, Txs: [][]byte{txBytes}, }) @@ -737,7 +737,7 @@ func TestABCI_FinalizeBlock_MultiMsg(t *testing.T) { txBytes, err = suite.txConfig.TxEncoder()(builder.GetTx()) require.NoError(t, err) - _, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ + _, err = suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{ Height: 1, Txs: [][]byte{txBytes}, }) @@ -768,7 +768,7 @@ func TestABCI_Query_SimulateTx(t *testing.T) { } suite := NewBaseAppSuite(t, anteOpt) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{}, }) require.NoError(t, err) @@ -797,7 +797,7 @@ func TestABCI_Query_SimulateTx(t *testing.T) { require.Equal(t, gasConsumed, gInfo.GasUsed) // simulate by calling Query with encoded tx - query := abci.RequestQuery{ + query := abci.QueryRequest{ Path: "/app/simulate", Data: txBytes, } @@ -813,7 +813,7 @@ func TestABCI_Query_SimulateTx(t *testing.T) { require.Equal(t, result.Events, simRes.Result.Events) require.True(t, bytes.Equal(result.Data, simRes.Result.Data)) - _, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: count}) + _, err = suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{Height: count}) require.NoError(t, err) _, err = suite.baseApp.Commit() require.NoError(t, err) @@ -830,18 +830,18 @@ func TestABCI_InvalidTransaction(t *testing.T) { suite := NewBaseAppSuite(t, anteOpt) baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), CounterServerImplGasMeterOnly{}) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{}, }) require.NoError(t, err) - _, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ + _, err = suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{ Height: 1, }) require.NoError(t, err) // malformed transaction bytes { bz := []byte("example vote extension") - result, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ + result, err := suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{ Height: 1, Txs: [][]byte{bz}, }) @@ -856,7 +856,7 @@ func TestABCI_InvalidTransaction(t *testing.T) { emptyTx := suite.txConfig.NewTxBuilder().GetTx() bz, err := suite.txConfig.TxEncoder()(emptyTx) require.NoError(t, err) - result, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ + result, err := suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{ Height: 1, Txs: [][]byte{bz}, }) @@ -963,12 +963,12 @@ func TestABCI_TxGasLimits(t *testing.T) { suite := NewBaseAppSuite(t, anteOpt) baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), CounterServerImplGasMeterOnly{}) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{}, }) require.NoError(t, err) - _, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ + _, err = suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{ Height: 1, }) require.NoError(t, err) @@ -1005,7 +1005,7 @@ func TestABCI_TxGasLimits(t *testing.T) { } // Deliver the txs - res, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ + res, err := suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{ Height: 2, Txs: txs, }) @@ -1055,7 +1055,7 @@ func TestABCI_MaxBlockGasLimits(t *testing.T) { suite := NewBaseAppSuite(t, anteOpt) baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), CounterServerImplGasMeterOnly{}) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{ Block: &cmtproto.BlockParams{ MaxGas: 100, @@ -1064,7 +1064,7 @@ func TestABCI_MaxBlockGasLimits(t *testing.T) { }) require.NoError(t, err) - _, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) + _, err = suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1}) require.NoError(t, err) testCases := []struct { @@ -1090,7 +1090,7 @@ func TestABCI_MaxBlockGasLimits(t *testing.T) { tx := tc.tx // reset block gas - _, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: suite.baseApp.LastBlockHeight() + 1}) + _, err := suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{Height: suite.baseApp.LastBlockHeight() + 1}) require.NoError(t, err) // execute the transaction multiple times @@ -1156,7 +1156,7 @@ func TestABCI_GasConsumptionBadTx(t *testing.T) { suite := NewBaseAppSuite(t, anteOpt) baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), CounterServerImplGasMeterOnly{}) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{ Block: &cmtproto.BlockParams{ MaxGas: 9, @@ -1175,7 +1175,7 @@ func TestABCI_GasConsumptionBadTx(t *testing.T) { txBytes2, err := suite.txConfig.TxEncoder()(tx) require.NoError(t, err) - _, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ + _, err = suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{ Height: suite.baseApp.LastBlockHeight() + 1, Txs: [][]byte{txBytes, txBytes2}, }) @@ -1195,7 +1195,7 @@ func TestABCI_Query(t *testing.T) { suite := NewBaseAppSuite(t, anteOpt) baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), CounterServerImplGasMeterOnly{}) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{}, }) require.NoError(t, err) @@ -1203,7 +1203,7 @@ func TestABCI_Query(t *testing.T) { // NOTE: "/store/key1" tells us KVStore // and the final "/key" says to use the data as the // key in the given KVStore ... - query := abci.RequestQuery{ + query := abci.QueryRequest{ Path: "/store/key1/key", Data: key, } @@ -1226,7 +1226,7 @@ func TestABCI_Query(t *testing.T) { bz, err := suite.txConfig.TxEncoder()(tx) require.NoError(t, err) - _, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ + _, err = suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{ Height: 1, Txs: [][]byte{bz}, }) @@ -1340,7 +1340,7 @@ func TestABCI_GetBlockRetentionHeight(t *testing.T) { tc := tc tc.bapp.SetParamStore(¶mStore{db: dbm.NewMemDB()}) - _, err := tc.bapp.InitChain(&abci.RequestInitChain{ + _, err := tc.bapp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{ Evidence: &cmtproto.EvidenceParams{ MaxAgeNumBlocks: tc.maxAgeBlocks, @@ -1370,7 +1370,7 @@ func TestPrepareCheckStateCalledWithCheckState(t *testing.T) { wasPrepareCheckStateCalled = true }) - _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) + _, err := app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1}) require.NoError(t, err) _, err = app.Commit() require.NoError(t, err) @@ -1394,7 +1394,7 @@ func TestPrecommiterCalledWithDeliverState(t *testing.T) { wasPrecommiterCalled = true }) - _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) + _, err := app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1}) require.NoError(t, err) _, err = app.Commit() require.NoError(t, err) @@ -1413,7 +1413,7 @@ func TestABCI_Proposal_HappyPath(t *testing.T) { baseapptestutil.RegisterKeyValueServer(suite.baseApp.MsgServiceRouter(), MsgKeyValueImpl{}) baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), NoopCounterServerImpl{}) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{}, }) require.NoError(t, err) @@ -1422,9 +1422,9 @@ func TestABCI_Proposal_HappyPath(t *testing.T) { txBytes, err := suite.txConfig.TxEncoder()(tx) require.NoError(t, err) - reqCheckTx := abci.RequestCheckTx{ + reqCheckTx := abci.CheckTxRequest{ Tx: txBytes, - Type: abci.CheckTxType_New, + Type: abci.CHECK_TX_TYPE_CHECK, } _, err = suite.baseApp.CheckTx(&reqCheckTx) require.NoError(t, err) @@ -1437,7 +1437,7 @@ func TestABCI_Proposal_HappyPath(t *testing.T) { err = pool.Insert(sdk.Context{}, tx2) require.NoError(t, err) - reqPrepareProposal := abci.RequestPrepareProposal{ + reqPrepareProposal := abci.PrepareProposalRequest{ MaxTxBytes: 1000, Height: 1, } @@ -1449,17 +1449,17 @@ func TestABCI_Proposal_HappyPath(t *testing.T) { txBytes, tx2Bytes, } - reqProcessProposal := abci.RequestProcessProposal{ + reqProcessProposal := abci.ProcessProposalRequest{ Txs: reqProposalTxBytes[:], Height: reqPrepareProposal.Height, } resProcessProposal, err := suite.baseApp.ProcessProposal(&reqProcessProposal) require.NoError(t, err) - require.Equal(t, abci.ResponseProcessProposal_ACCEPT, resProcessProposal.Status) + require.Equal(t, abci.PROCESS_PROPOSAL_STATUS_ACCEPT, resProcessProposal.Status) // the same txs as in PrepareProposal - res, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ + res, err := suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{ Height: suite.baseApp.LastBlockHeight() + 1, Txs: reqProposalTxBytes[:], }) @@ -1475,30 +1475,30 @@ func TestABCI_Proposal_Read_State_PrepareProposal(t *testing.T) { someKey := []byte("some-key") setInitChainerOpt := func(bapp *baseapp.BaseApp) { - bapp.SetInitChainer(func(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { + bapp.SetInitChainer(func(ctx sdk.Context, req *abci.InitChainRequest) (*abci.InitChainResponse, error) { ctx.KVStore(capKey1).Set(someKey, []byte(fooStr)) - return &abci.ResponseInitChain{}, nil + return &abci.InitChainResponse{}, nil }) } prepareOpt := func(bapp *baseapp.BaseApp) { - bapp.SetPrepareProposal(func(ctx sdk.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) { + bapp.SetPrepareProposal(func(ctx sdk.Context, req *abci.PrepareProposalRequest) (*abci.PrepareProposalResponse, error) { value := ctx.KVStore(capKey1).Get(someKey) // We should be able to access any state written in InitChain require.Equal(t, fooStr, string(value)) - return &abci.ResponsePrepareProposal{Txs: req.Txs}, nil + return &abci.PrepareProposalResponse{Txs: req.Txs}, nil }) } suite := NewBaseAppSuite(t, setInitChainerOpt, prepareOpt) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ InitialHeight: 1, ConsensusParams: &cmtproto.ConsensusParams{}, }) require.NoError(t, err) - reqPrepareProposal := abci.RequestPrepareProposal{ + reqPrepareProposal := abci.PrepareProposalRequest{ MaxTxBytes: 1000, Height: 1, // this value can't be 0 } @@ -1507,50 +1507,50 @@ func TestABCI_Proposal_Read_State_PrepareProposal(t *testing.T) { require.Equal(t, 0, len(resPrepareProposal.Txs)) reqProposalTxBytes := [][]byte{} - reqProcessProposal := abci.RequestProcessProposal{ + reqProcessProposal := abci.ProcessProposalRequest{ Txs: reqProposalTxBytes, Height: reqPrepareProposal.Height, } resProcessProposal, err := suite.baseApp.ProcessProposal(&reqProcessProposal) require.NoError(t, err) - require.Equal(t, abci.ResponseProcessProposal_ACCEPT, resProcessProposal.Status) + require.Equal(t, abci.PROCESS_PROPOSAL_STATUS_ACCEPT, resProcessProposal.Status) } func TestABCI_Proposals_WithVE(t *testing.T) { someVoteExtension := []byte("some-vote-extension") setInitChainerOpt := func(bapp *baseapp.BaseApp) { - bapp.SetInitChainer(func(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { - return &abci.ResponseInitChain{}, nil + bapp.SetInitChainer(func(ctx sdk.Context, req *abci.InitChainRequest) (*abci.InitChainResponse, error) { + return &abci.InitChainResponse{}, nil }) } prepareOpt := func(bapp *baseapp.BaseApp) { - bapp.SetPrepareProposal(func(ctx sdk.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) { + bapp.SetPrepareProposal(func(ctx sdk.Context, req *abci.PrepareProposalRequest) (*abci.PrepareProposalResponse, error) { // Inject the vote extension to the beginning of the proposal txs := make([][]byte, len(req.Txs)+1) txs[0] = someVoteExtension copy(txs[1:], req.Txs) - return &abci.ResponsePrepareProposal{Txs: txs}, nil + return &abci.PrepareProposalResponse{Txs: txs}, nil }) - bapp.SetProcessProposal(func(ctx sdk.Context, req *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) { + bapp.SetProcessProposal(func(ctx sdk.Context, req *abci.ProcessProposalRequest) (*abci.ProcessProposalResponse, error) { // Check that the vote extension is still there require.Equal(t, someVoteExtension, req.Txs[0]) - return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_ACCEPT}, nil + return &abci.ProcessProposalResponse{Status: abci.PROCESS_PROPOSAL_STATUS_ACCEPT}, nil }) } suite := NewBaseAppSuite(t, setInitChainerOpt, prepareOpt) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ InitialHeight: 1, ConsensusParams: &cmtproto.ConsensusParams{}, }) require.NoError(t, err) - reqPrepareProposal := abci.RequestPrepareProposal{ + reqPrepareProposal := abci.PrepareProposalRequest{ MaxTxBytes: 100000, Height: 1, // this value can't be 0 } @@ -1558,17 +1558,17 @@ func TestABCI_Proposals_WithVE(t *testing.T) { require.NoError(t, err) require.Equal(t, 1, len(resPrepareProposal.Txs)) - reqProcessProposal := abci.RequestProcessProposal{ + reqProcessProposal := abci.ProcessProposalRequest{ Txs: resPrepareProposal.Txs, Height: reqPrepareProposal.Height, } resProcessProposal, err := suite.baseApp.ProcessProposal(&reqProcessProposal) require.NoError(t, err) - require.Equal(t, abci.ResponseProcessProposal_ACCEPT, resProcessProposal.Status) + require.Equal(t, abci.PROCESS_PROPOSAL_STATUS_ACCEPT, resProcessProposal.Status) // Run finalize block and ensure that the vote extension is still there and that // the proposal is accepted - result, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ + result, err := suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{ Txs: resPrepareProposal.Txs, Height: reqPrepareProposal.Height, }) @@ -1590,7 +1590,7 @@ func TestABCI_PrepareProposal_ReachedMaxBytes(t *testing.T) { suite := NewBaseAppSuite(t, anteOpt, baseapp.SetMempool(pool)) baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), NoopCounterServerImpl{}) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{}, }) require.NoError(t, err) @@ -1601,7 +1601,7 @@ func TestABCI_PrepareProposal_ReachedMaxBytes(t *testing.T) { require.NoError(t, err) } - reqPrepareProposal := abci.RequestPrepareProposal{ + reqPrepareProposal := abci.PrepareProposalRequest{ MaxTxBytes: 1500, Height: 1, } @@ -1620,7 +1620,7 @@ func TestABCI_PrepareProposal_BadEncoding(t *testing.T) { suite := NewBaseAppSuite(t, anteOpt, baseapp.SetMempool(pool)) baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), NoopCounterServerImpl{}) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{}, }) require.NoError(t, err) @@ -1629,7 +1629,7 @@ func TestABCI_PrepareProposal_BadEncoding(t *testing.T) { err = pool.Insert(sdk.Context{}, tx) require.NoError(t, err) - reqPrepareProposal := abci.RequestPrepareProposal{ + reqPrepareProposal := abci.PrepareProposalRequest{ MaxTxBytes: 1000, Height: 1, } @@ -1644,7 +1644,7 @@ func TestABCI_PrepareProposal_OverGasUnderBytes(t *testing.T) { baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), NoopCounterServerImpl{}) // set max block gas limit to 99, this will allow 9 txs of 10 gas each. - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{ Block: &cmtproto.BlockParams{MaxGas: 99}, }, @@ -1669,7 +1669,7 @@ func TestABCI_PrepareProposal_OverGasUnderBytes(t *testing.T) { } // ensure we only select transactions that fit within the block gas limit - res, err := suite.baseApp.PrepareProposal(&abci.RequestPrepareProposal{ + res, err := suite.baseApp.PrepareProposal(&abci.PrepareProposalRequest{ MaxTxBytes: 1_000_000, // large enough to ignore restriction Height: 1, }) @@ -1685,7 +1685,7 @@ func TestABCI_PrepareProposal_MaxGas(t *testing.T) { baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), NoopCounterServerImpl{}) // set max block gas limit to 100 - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{ Block: &cmtproto.BlockParams{MaxGas: 100}, }, @@ -1709,7 +1709,7 @@ func TestABCI_PrepareProposal_MaxGas(t *testing.T) { } // ensure we only select transactions that fit within the block gas limit - res, err := suite.baseApp.PrepareProposal(&abci.RequestPrepareProposal{ + res, err := suite.baseApp.PrepareProposal(&abci.PrepareProposalRequest{ MaxTxBytes: 1_000_000, // large enough to ignore restriction Height: 1, }) @@ -1727,7 +1727,7 @@ func TestABCI_PrepareProposal_Failures(t *testing.T) { suite := NewBaseAppSuite(t, anteOpt, baseapp.SetMempool(pool)) baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), NoopCounterServerImpl{}) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{}, }) require.NoError(t, err) @@ -1736,9 +1736,9 @@ func TestABCI_PrepareProposal_Failures(t *testing.T) { txBytes, err := suite.txConfig.TxEncoder()(tx) require.NoError(t, err) - reqCheckTx := abci.RequestCheckTx{ + reqCheckTx := abci.CheckTxRequest{ Tx: txBytes, - Type: abci.CheckTxType_New, + Type: abci.CHECK_TX_TYPE_CHECK, } checkTxRes, err := suite.baseApp.CheckTx(&reqCheckTx) require.NoError(t, err) @@ -1751,7 +1751,7 @@ func TestABCI_PrepareProposal_Failures(t *testing.T) { require.NoError(t, err) require.Equal(t, 2, pool.CountTx()) - req := abci.RequestPrepareProposal{ + req := abci.PrepareProposalRequest{ MaxTxBytes: 1000, Height: 1, } @@ -1762,18 +1762,18 @@ func TestABCI_PrepareProposal_Failures(t *testing.T) { func TestABCI_PrepareProposal_PanicRecovery(t *testing.T) { prepareOpt := func(app *baseapp.BaseApp) { - app.SetPrepareProposal(func(ctx sdk.Context, rpp *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) { + app.SetPrepareProposal(func(ctx sdk.Context, rpp *abci.PrepareProposalRequest) (*abci.PrepareProposalResponse, error) { panic(errors.New("test")) }) } suite := NewBaseAppSuite(t, prepareOpt) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{}, }) require.NoError(t, err) - req := abci.RequestPrepareProposal{ + req := abci.PrepareProposalRequest{ MaxTxBytes: 1000, Height: 1, } @@ -1803,7 +1803,7 @@ func TestABCI_PrepareProposal_VoteExtensions(t *testing.T) { // set up baseapp prepareOpt := func(bapp *baseapp.BaseApp) { - bapp.SetPrepareProposal(func(ctx sdk.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) { + bapp.SetPrepareProposal(func(ctx sdk.Context, req *abci.PrepareProposalRequest) (*abci.PrepareProposalResponse, error) { ctx = ctx.WithBlockHeight(req.Height).WithChainID(bapp.ChainID()) _, info := extendedCommitToLastCommit(req.LocalLastCommit) ctx = ctx.WithCometInfo(info) @@ -1817,13 +1817,13 @@ func TestABCI_PrepareProposal_VoteExtensions(t *testing.T) { if extsEnabled { req.Txs = append(req.Txs, []byte("some-tx-that-does-something-from-votes")) } - return &abci.ResponsePrepareProposal{Txs: req.Txs}, nil + return &abci.PrepareProposalResponse{Txs: req.Txs}, nil }) } suite := NewBaseAppSuite(t, prepareOpt) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ InitialHeight: 1, ConsensusParams: &cmtproto.ConsensusParams{ Abci: &cmtproto.ABCIParams{ @@ -1834,7 +1834,7 @@ func TestABCI_PrepareProposal_VoteExtensions(t *testing.T) { require.NoError(t, err) // first test without vote extensions, no new txs should be added - reqPrepareProposal := abci.RequestPrepareProposal{ + reqPrepareProposal := abci.PrepareProposalRequest{ MaxTxBytes: 1000, Height: 1, // this value can't be 0 } @@ -1866,7 +1866,7 @@ func TestABCI_PrepareProposal_VoteExtensions(t *testing.T) { extSig, err := privkey.Sign(bz) require.NoError(t, err) - reqPrepareProposal = abci.RequestPrepareProposal{ + reqPrepareProposal = abci.PrepareProposalRequest{ MaxTxBytes: 1000, Height: 3, // this value can't be 0 LocalLastCommit: abci.ExtendedCommitInfo{ @@ -1889,7 +1889,7 @@ func TestABCI_PrepareProposal_VoteExtensions(t *testing.T) { require.Equal(t, 1, len(resPrepareProposal.Txs)) // now vote extensions but our sole voter doesn't reach majority - reqPrepareProposal = abci.RequestPrepareProposal{ + reqPrepareProposal = abci.PrepareProposalRequest{ MaxTxBytes: 1000, Height: 3, // this value can't be 0 LocalLastCommit: abci.ExtendedCommitInfo{ @@ -1914,21 +1914,21 @@ func TestABCI_PrepareProposal_VoteExtensions(t *testing.T) { func TestABCI_ProcessProposal_PanicRecovery(t *testing.T) { processOpt := func(app *baseapp.BaseApp) { - app.SetProcessProposal(func(ctx sdk.Context, rpp *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) { + app.SetProcessProposal(func(ctx sdk.Context, rpp *abci.ProcessProposalRequest) (*abci.ProcessProposalResponse, error) { panic(errors.New("test")) }) } suite := NewBaseAppSuite(t, processOpt) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{}, }) require.NoError(t, err) require.NotPanics(t, func() { - res, err := suite.baseApp.ProcessProposal(&abci.RequestProcessProposal{Height: 1}) + res, err := suite.baseApp.ProcessProposal(&abci.ProcessProposalRequest{Height: 1}) require.NoError(t, err) - require.Equal(t, res.Status, abci.ResponseProcessProposal_REJECT) + require.Equal(t, res.Status, abci.PROCESS_PROPOSAL_STATUS_REJECT) }) } @@ -1940,31 +1940,31 @@ func TestABCI_Proposal_Reset_State_Between_Calls(t *testing.T) { someKey := []byte("some-key") prepareOpt := func(bapp *baseapp.BaseApp) { - bapp.SetPrepareProposal(func(ctx sdk.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) { + bapp.SetPrepareProposal(func(ctx sdk.Context, req *abci.PrepareProposalRequest) (*abci.PrepareProposalResponse, error) { // This key should not exist given that we reset the state on every call. require.False(t, ctx.KVStore(capKey1).Has(someKey)) ctx.KVStore(capKey1).Set(someKey, someKey) - return &abci.ResponsePrepareProposal{Txs: req.Txs}, nil + return &abci.PrepareProposalResponse{Txs: req.Txs}, nil }) } processOpt := func(bapp *baseapp.BaseApp) { - bapp.SetProcessProposal(func(ctx sdk.Context, req *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) { + bapp.SetProcessProposal(func(ctx sdk.Context, req *abci.ProcessProposalRequest) (*abci.ProcessProposalResponse, error) { // This key should not exist given that we reset the state on every call. require.False(t, ctx.KVStore(capKey1).Has(someKey)) ctx.KVStore(capKey1).Set(someKey, someKey) - return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_ACCEPT}, nil + return &abci.ProcessProposalResponse{Status: abci.PROCESS_PROPOSAL_STATUS_ACCEPT}, nil }) } suite := NewBaseAppSuite(t, prepareOpt, processOpt) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{}, }) require.NoError(t, err) - reqPrepareProposal := abci.RequestPrepareProposal{ + reqPrepareProposal := abci.PrepareProposalRequest{ MaxTxBytes: 1000, Height: 2, // this value can't be 0 } @@ -1978,7 +1978,7 @@ func TestABCI_Proposal_Reset_State_Between_Calls(t *testing.T) { } reqProposalTxBytes := [][]byte{} - reqProcessProposal := abci.RequestProcessProposal{ + reqProcessProposal := abci.ProcessProposalRequest{ Txs: reqProposalTxBytes, Height: 2, } @@ -1988,7 +1988,7 @@ func TestABCI_Proposal_Reset_State_Between_Calls(t *testing.T) { for i := 0; i < 5; i++ { resProcessProposal, err := suite.baseApp.ProcessProposal(&reqProcessProposal) require.NoError(t, err) - require.Equal(t, abci.ResponseProcessProposal_ACCEPT, resProcessProposal.Status) + require.Equal(t, abci.PROCESS_PROPOSAL_STATUS_ACCEPT, resProcessProposal.Status) } } @@ -2011,13 +2011,13 @@ func TestABCI_HaltChain(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { suite := NewBaseAppSuite(t, baseapp.SetHaltHeight(tc.haltHeight), baseapp.SetHaltTime(tc.haltTime)) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{}, InitialHeight: tc.blockHeight, }) require.NoError(t, err) app := suite.baseApp - _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{ + _, err = app.FinalizeBlock(&abci.FinalizeBlockRequest{ Height: tc.blockHeight, Time: time.Unix(tc.blockTime, 0), }) @@ -2037,31 +2037,31 @@ func TestBaseApp_PreBlocker(t *testing.T) { logger := log.NewTestLogger(t) app := baseapp.NewBaseApp(name, logger, db, nil) - _, err := app.InitChain(&abci.RequestInitChain{}) + _, err := app.InitChain(&abci.InitChainRequest{}) require.NoError(t, err) wasHookCalled := false - app.SetPreBlocker(func(ctx sdk.Context, req *abci.RequestFinalizeBlock) error { + app.SetPreBlocker(func(ctx sdk.Context, req *abci.FinalizeBlockRequest) error { wasHookCalled = true return nil }) app.Seal() - _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) + _, err = app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1}) require.NoError(t, err) require.Equal(t, true, wasHookCalled) // Now try erroring app = baseapp.NewBaseApp(name, logger, db, nil) - _, err = app.InitChain(&abci.RequestInitChain{}) + _, err = app.InitChain(&abci.InitChainRequest{}) require.NoError(t, err) - app.SetPreBlocker(func(ctx sdk.Context, req *abci.RequestFinalizeBlock) error { + app.SetPreBlocker(func(ctx sdk.Context, req *abci.FinalizeBlockRequest) error { return errors.New("some error") }) app.Seal() - _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) + _, err = app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1}) require.Error(t, err) } @@ -2091,26 +2091,26 @@ func TestBaseApp_VoteExtensions(t *testing.T) { } baseappOpts := func(app *baseapp.BaseApp) { - app.SetExtendVoteHandler(func(sdk.Context, *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) { + app.SetExtendVoteHandler(func(sdk.Context, *abci.ExtendVoteRequest) (*abci.ExtendVoteResponse, error) { // here we would have a process to get the price from an external source price := 10000000 + rand.Int63n(1000000) ve := make([]byte, 8) binary.BigEndian.PutUint64(ve, uint64(price)) - return &abci.ResponseExtendVote{VoteExtension: ve}, nil + return &abci.ExtendVoteResponse{VoteExtension: ve}, nil }) - app.SetVerifyVoteExtensionHandler(func(_ sdk.Context, req *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) { + app.SetVerifyVoteExtensionHandler(func(_ sdk.Context, req *abci.VerifyVoteExtensionRequest) (*abci.VerifyVoteExtensionResponse, error) { vePrice := binary.BigEndian.Uint64(req.VoteExtension) // here we would do some price validation, must not be 0 and not too high if vePrice > 11000000 || vePrice == 0 { // usually application should always return ACCEPT unless they really want to discard the entire vote - return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + return &abci.VerifyVoteExtensionResponse{Status: abci.VERIFY_VOTE_EXTENSION_STATUS_REJECT}, nil } - return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_ACCEPT}, nil + return &abci.VerifyVoteExtensionResponse{Status: abci.VERIFY_VOTE_EXTENSION_STATUS_ACCEPT}, nil }) - app.SetPrepareProposal(func(ctx sdk.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) { + app.SetPrepareProposal(func(ctx sdk.Context, req *abci.PrepareProposalRequest) (*abci.PrepareProposalResponse, error) { txs := [][]byte{} ctx = ctx.WithBlockHeight(req.Height).WithChainID(app.ChainID()) _, info := extendedCommitToLastCommit(req.LocalLastCommit) @@ -2128,25 +2128,25 @@ func TestBaseApp_VoteExtensions(t *testing.T) { } } - return &abci.ResponsePrepareProposal{Txs: txs}, nil + return &abci.PrepareProposalResponse{Txs: txs}, nil }) - app.SetProcessProposal(func(ctx sdk.Context, req *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) { + app.SetProcessProposal(func(ctx sdk.Context, req *abci.ProcessProposalRequest) (*abci.ProcessProposalResponse, error) { // here we check if the proposal is valid, mainly if the vote extensions appended to the txs are valid for _, v := range req.Txs { // pretend this is a way to check if the tx is actually a VE if len(v) == 8 { // pretend this is a way to check if the VE is valid if binary.BigEndian.Uint64(v) > 11000000 || binary.BigEndian.Uint64(v) == 0 { - return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_REJECT}, nil + return &abci.ProcessProposalResponse{Status: abci.PROCESS_PROPOSAL_STATUS_REJECT}, nil } } } - return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_ACCEPT}, nil + return &abci.ProcessProposalResponse{Status: abci.PROCESS_PROPOSAL_STATUS_ACCEPT}, nil }) - app.SetPreBlocker(func(ctx sdk.Context, req *abci.RequestFinalizeBlock) error { + app.SetPreBlocker(func(ctx sdk.Context, req *abci.FinalizeBlockRequest) error { count := uint64(0) pricesSum := uint64(0) for _, v := range req.Txs { @@ -2171,7 +2171,7 @@ func TestBaseApp_VoteExtensions(t *testing.T) { suite := NewBaseAppSuite(t, baseappOpts) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{ Abci: &cmtproto.ABCIParams{ VoteExtensionsEnableHeight: 1, @@ -2183,7 +2183,7 @@ func TestBaseApp_VoteExtensions(t *testing.T) { allVEs := [][]byte{} // simulate getting 10 vote extensions from 10 validators for i := 0; i < 10; i++ { - ve, err := suite.baseApp.ExtendVote(context.TODO(), &abci.RequestExtendVote{Height: 1}) + ve, err := suite.baseApp.ExtendVote(context.TODO(), &abci.ExtendVoteRequest{Height: 1}) require.NoError(t, err) allVEs = append(allVEs, ve.VoteExtension) } @@ -2202,12 +2202,12 @@ func TestBaseApp_VoteExtensions(t *testing.T) { // verify all votes, only 10 should be accepted successful := 0 for _, v := range allVEs { - res, err := suite.baseApp.VerifyVoteExtension(&abci.RequestVerifyVoteExtension{ + res, err := suite.baseApp.VerifyVoteExtension(&abci.VerifyVoteExtensionRequest{ Height: 1, VoteExtension: v, }) require.NoError(t, err) - if res.Status == abci.ResponseVerifyVoteExtension_ACCEPT { + if res.Status == abci.VERIFY_VOTE_EXTENSION_STATUS_ACCEPT { successful++ } } @@ -2227,7 +2227,7 @@ func TestBaseApp_VoteExtensions(t *testing.T) { ) } - prepPropReq := &abci.RequestPrepareProposal{ + prepPropReq := &abci.PrepareProposalRequest{ Height: 1, LocalLastCommit: abci.ExtendedCommitInfo{ Round: 0, @@ -2253,11 +2253,11 @@ func TestBaseApp_VoteExtensions(t *testing.T) { require.NoError(t, err) require.Len(t, resp.Txs, 0) - procPropRes, err := suite.baseApp.ProcessProposal(&abci.RequestProcessProposal{Height: 1, Txs: resp.Txs}) + procPropRes, err := suite.baseApp.ProcessProposal(&abci.ProcessProposalRequest{Height: 1, Txs: resp.Txs}) require.NoError(t, err) - require.Equal(t, abci.ResponseProcessProposal_ACCEPT, procPropRes.Status) + require.Equal(t, abci.PROCESS_PROPOSAL_STATUS_ACCEPT, procPropRes.Status) - _, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1, Txs: resp.Txs}) + _, err = suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1, Txs: resp.Txs}) require.NoError(t, err) // The average price will be nil during the first block, given that we don't have @@ -2300,11 +2300,11 @@ func TestBaseApp_VoteExtensions(t *testing.T) { require.NoError(t, err) require.Len(t, resp.Txs, 10) - procPropRes, err = suite.baseApp.ProcessProposal(&abci.RequestProcessProposal{Height: 2, Txs: resp.Txs}) + procPropRes, err = suite.baseApp.ProcessProposal(&abci.ProcessProposalRequest{Height: 2, Txs: resp.Txs}) require.NoError(t, err) - require.Equal(t, abci.ResponseProcessProposal_ACCEPT, procPropRes.Status) + require.Equal(t, abci.PROCESS_PROPOSAL_STATUS_ACCEPT, procPropRes.Status) - _, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 2, Txs: resp.Txs}) + _, err = suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 2, Txs: resp.Txs}) require.NoError(t, err) // Check if the average price was available in FinalizeBlock's context @@ -2323,25 +2323,25 @@ func TestBaseApp_VoteExtensions(t *testing.T) { func TestABCI_PrepareProposal_Panic(t *testing.T) { prepareOpt := func(bapp *baseapp.BaseApp) { - bapp.SetPrepareProposal(func(ctx sdk.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) { + bapp.SetPrepareProposal(func(ctx sdk.Context, req *abci.PrepareProposalRequest) (*abci.PrepareProposalResponse, error) { if len(req.Txs) == 3 { panic("i don't like number 3, panic") } // return empty if no panic - return &abci.ResponsePrepareProposal{}, nil + return &abci.PrepareProposalResponse{}, nil }) } suite := NewBaseAppSuite(t, prepareOpt) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ InitialHeight: 1, ConsensusParams: &cmtproto.ConsensusParams{}, }) require.NoError(t, err) txs := [][]byte{{1}, {2}} - reqPrepareProposal := abci.RequestPrepareProposal{ + reqPrepareProposal := abci.PrepareProposalRequest{ MaxTxBytes: 1000, Height: 1, // this value can't be 0 Txs: txs, @@ -2361,7 +2361,7 @@ func TestABCI_PrepareProposal_Panic(t *testing.T) { func TestOptimisticExecution(t *testing.T) { suite := NewBaseAppSuite(t, baseapp.SetOptimisticExecution()) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{}, }) require.NoError(t, err) @@ -2372,17 +2372,17 @@ func TestOptimisticExecution(t *testing.T) { txBytes, err := suite.txConfig.TxEncoder()(tx) require.NoError(t, err) - reqProcProp := abci.RequestProcessProposal{ + reqProcProp := abci.ProcessProposalRequest{ Txs: [][]byte{txBytes}, Height: suite.baseApp.LastBlockHeight() + 1, Hash: []byte("some-hash" + strconv.FormatInt(suite.baseApp.LastBlockHeight()+1, 10)), } respProcProp, err := suite.baseApp.ProcessProposal(&reqProcProp) - require.Equal(t, abci.ResponseProcessProposal_ACCEPT, respProcProp.Status) + require.Equal(t, abci.PROCESS_PROPOSAL_STATUS_ACCEPT, respProcProp.Status) require.NoError(t, err) - reqFinalizeBlock := abci.RequestFinalizeBlock{ + reqFinalizeBlock := abci.FinalizeBlockRequest{ Height: reqProcProp.Height, Txs: reqProcProp.Txs, Hash: reqProcProp.Hash, diff --git a/baseapp/abci_utils.go b/baseapp/abci_utils.go index c3b0b32eefba..a3ef8ed0cf59 100644 --- a/baseapp/abci_utils.go +++ b/baseapp/abci_utils.go @@ -247,7 +247,7 @@ func (h *DefaultProposalHandler) SetTxSelector(ts TxSelector) { // requested from CometBFT will simply be returned, which, by default, are in // FIFO order. func (h *DefaultProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHandler { - return func(ctx sdk.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) { + return func(ctx sdk.Context, req *abci.PrepareProposalRequest) (*abci.PrepareProposalResponse, error) { var maxBlockGas uint64 if b := ctx.ConsensusParams().Block; b != nil { maxBlockGas = uint64(b.MaxGas) @@ -273,7 +273,7 @@ func (h *DefaultProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHan } } - return &abci.ResponsePrepareProposal{Txs: h.txSelector.SelectedTxs(ctx)}, nil + return &abci.PrepareProposalResponse{Txs: h.txSelector.SelectedTxs(ctx)}, nil } iterator := h.mempool.Select(ctx, req.Txs) @@ -348,7 +348,7 @@ func (h *DefaultProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHan iterator = iterator.Next() } - return &abci.ResponsePrepareProposal{Txs: h.txSelector.SelectedTxs(ctx)}, nil + return &abci.PrepareProposalResponse{Txs: h.txSelector.SelectedTxs(ctx)}, nil } } @@ -371,7 +371,7 @@ func (h *DefaultProposalHandler) ProcessProposalHandler() sdk.ProcessProposalHan return NoOpProcessProposal() } - return func(ctx sdk.Context, req *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) { + return func(ctx sdk.Context, req *abci.ProcessProposalRequest) (*abci.ProcessProposalResponse, error) { var totalTxGas uint64 var maxBlockGas int64 @@ -382,7 +382,7 @@ func (h *DefaultProposalHandler) ProcessProposalHandler() sdk.ProcessProposalHan for _, txBytes := range req.Txs { tx, err := h.txVerifier.ProcessProposalVerifyTx(txBytes) if err != nil { - return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_REJECT}, nil + return &abci.ProcessProposalResponse{Status: abci.PROCESS_PROPOSAL_STATUS_REJECT}, nil } if maxBlockGas > 0 { @@ -392,44 +392,44 @@ func (h *DefaultProposalHandler) ProcessProposalHandler() sdk.ProcessProposalHan } if totalTxGas > uint64(maxBlockGas) { - return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_REJECT}, nil + return &abci.ProcessProposalResponse{Status: abci.PROCESS_PROPOSAL_STATUS_REJECT}, nil } } } - return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_ACCEPT}, nil + return &abci.ProcessProposalResponse{Status: abci.PROCESS_PROPOSAL_STATUS_ACCEPT}, nil } } // NoOpPrepareProposal defines a no-op PrepareProposal handler. It will always // return the transactions sent by the client's request. func NoOpPrepareProposal() sdk.PrepareProposalHandler { - return func(_ sdk.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) { - return &abci.ResponsePrepareProposal{Txs: req.Txs}, nil + return func(_ sdk.Context, req *abci.PrepareProposalRequest) (*abci.PrepareProposalResponse, error) { + return &abci.PrepareProposalResponse{Txs: req.Txs}, nil } } // NoOpProcessProposal defines a no-op ProcessProposal Handler. It will always // return ACCEPT. func NoOpProcessProposal() sdk.ProcessProposalHandler { - return func(_ sdk.Context, _ *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) { - return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_ACCEPT}, nil + return func(_ sdk.Context, _ *abci.ProcessProposalRequest) (*abci.ProcessProposalResponse, error) { + return &abci.ProcessProposalResponse{Status: abci.PROCESS_PROPOSAL_STATUS_ACCEPT}, nil } } // NoOpExtendVote defines a no-op ExtendVote handler. It will always return an // empty byte slice as the vote extension. func NoOpExtendVote() sdk.ExtendVoteHandler { - return func(_ sdk.Context, _ *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) { - return &abci.ResponseExtendVote{VoteExtension: []byte{}}, nil + return func(_ sdk.Context, _ *abci.ExtendVoteRequest) (*abci.ExtendVoteResponse, error) { + return &abci.ExtendVoteResponse{VoteExtension: []byte{}}, nil } } // NoOpVerifyVoteExtensionHandler defines a no-op VerifyVoteExtension handler. It // will always return an ACCEPT status with no error. func NoOpVerifyVoteExtensionHandler() sdk.VerifyVoteExtensionHandler { - return func(_ sdk.Context, _ *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) { - return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_ACCEPT}, nil + return func(_ sdk.Context, _ *abci.VerifyVoteExtensionRequest) (*abci.VerifyVoteExtensionResponse, error) { + return &abci.VerifyVoteExtensionResponse{Status: abci.VERIFY_VOTE_EXTENSION_STATUS_ACCEPT}, nil } } diff --git a/baseapp/abci_utils_test.go b/baseapp/abci_utils_test.go index 23ac048b6727..93d15348cb97 100644 --- a/baseapp/abci_utils_test.go +++ b/baseapp/abci_utils_test.go @@ -499,12 +499,12 @@ func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_NoOpMempoolTxSelection() testCases := map[string]struct { ctx sdk.Context - req *abci.RequestPrepareProposal + req *abci.PrepareProposalRequest expectedTxs int }{ "small max tx bytes": { ctx: s.ctx, - req: &abci.RequestPrepareProposal{ + req: &abci.PrepareProposalRequest{ Txs: [][]byte{txBz, txBz, txBz, txBz, txBz}, MaxTxBytes: 10, }, @@ -516,7 +516,7 @@ func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_NoOpMempoolTxSelection() MaxGas: 10, }, }), - req: &abci.RequestPrepareProposal{ + req: &abci.PrepareProposalRequest{ Txs: [][]byte{txBz, txBz, txBz, txBz, txBz}, MaxTxBytes: 465, }, @@ -524,7 +524,7 @@ func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_NoOpMempoolTxSelection() }, "large max tx bytes": { ctx: s.ctx, - req: &abci.RequestPrepareProposal{ + req: &abci.PrepareProposalRequest{ Txs: [][]byte{txBz, txBz, txBz, txBz, txBz}, MaxTxBytes: 465, }, @@ -532,7 +532,7 @@ func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_NoOpMempoolTxSelection() }, "large max tx bytes len calculation": { ctx: s.ctx, - req: &abci.RequestPrepareProposal{ + req: &abci.PrepareProposalRequest{ Txs: [][]byte{txBz, txBz, txBz, txBz, txBz}, MaxTxBytes: 456, }, @@ -544,7 +544,7 @@ func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_NoOpMempoolTxSelection() MaxGas: 200, }, }), - req: &abci.RequestPrepareProposal{ + req: &abci.PrepareProposalRequest{ Txs: [][]byte{txBz, txBz, txBz, txBz, txBz}, MaxTxBytes: 465, }, @@ -628,14 +628,14 @@ func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_PriorityNonceMempoolTxSe testCases := map[string]struct { ctx sdk.Context txInputs []testTx - req *abci.RequestPrepareProposal + req *abci.PrepareProposalRequest handler sdk.PrepareProposalHandler expectedTxs []int }{ "skip same-sender non-sequential sequence and then add others txs": { ctx: s.ctx, txInputs: []testTx{testTxs[0], testTxs[1], testTxs[2], testTxs[3]}, - req: &abci.RequestPrepareProposal{ + req: &abci.PrepareProposalRequest{ MaxTxBytes: 180 + 181, }, expectedTxs: []int{0, 3}, @@ -643,7 +643,7 @@ func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_PriorityNonceMempoolTxSe "skip multi-signers msg non-sequential sequence": { ctx: s.ctx, txInputs: []testTx{testTxs[4], testTxs[5], testTxs[6], testTxs[7], testTxs[8]}, - req: &abci.RequestPrepareProposal{ + req: &abci.PrepareProposalRequest{ MaxTxBytes: 263 + 264, }, expectedTxs: []int{4, 8}, @@ -652,7 +652,7 @@ func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_PriorityNonceMempoolTxSe // Because tx 10 is valid, tx 11 can't be valid as they have higher sequence numbers. ctx: s.ctx, txInputs: []testTx{testTxs[9], testTxs[10], testTxs[11]}, - req: &abci.RequestPrepareProposal{ + req: &abci.PrepareProposalRequest{ MaxTxBytes: 263 + 264, }, expectedTxs: []int{9}, @@ -662,7 +662,7 @@ func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_PriorityNonceMempoolTxSe // the rest of the txs fail because they have a seq of 4. ctx: s.ctx, txInputs: []testTx{testTxs[12], testTxs[13], testTxs[14]}, - req: &abci.RequestPrepareProposal{ + req: &abci.PrepareProposalRequest{ MaxTxBytes: 112, }, expectedTxs: []int{}, diff --git a/baseapp/baseapp_test.go b/baseapp/baseapp_test.go index 2f7e2a4c1c6c..d1017d4fd8bf 100644 --- a/baseapp/baseapp_test.go +++ b/baseapp/baseapp_test.go @@ -99,12 +99,12 @@ func getQueryBaseapp(t *testing.T) *baseapp.BaseApp { name := t.Name() app := baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil) - _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) + _, err := app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1}) require.NoError(t, err) _, err = app.Commit() require.NoError(t, err) - _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 2}) + _, err = app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 2}) require.NoError(t, err) _, err = app.Commit() require.NoError(t, err) @@ -129,7 +129,7 @@ func NewBaseAppSuiteWithSnapshots(t *testing.T, cfg SnapshotsConfig, opts ...fun baseapptestutil.RegisterKeyValueServer(suite.baseApp.MsgServiceRouter(), MsgKeyValueImpl{}) - _, err = suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err = suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{}, }) require.NoError(t, err) @@ -165,7 +165,7 @@ func NewBaseAppSuiteWithSnapshots(t *testing.T, cfg SnapshotsConfig, opts ...fun txs = append(txs, txBytes) } - _, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ + _, err := suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{ Height: height, Txs: txs, }) @@ -216,7 +216,7 @@ func TestAnteHandlerGasMeter(t *testing.T) { } suite := NewBaseAppSuite(t, anteOpt, beginBlockerOpt) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{}, }) require.NoError(t, err) @@ -227,7 +227,7 @@ func TestAnteHandlerGasMeter(t *testing.T) { tx := newTxCounter(t, suite.txConfig, 0, 0) txBytes, err := suite.txConfig.TxEncoder()(tx) require.NoError(t, err) - _, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1, Txs: [][]byte{txBytes}}) + _, err = suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1, Txs: [][]byte{txBytes}}) require.NoError(t, err) } @@ -253,14 +253,14 @@ func TestLoadVersion(t *testing.T) { require.Equal(t, emptyCommitID, lastID) // execute a block, collect commit ID - res, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) + res, err := app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1}) require.NoError(t, err) commitID1 := storetypes.CommitID{Version: 1, Hash: res.AppHash} _, err = app.Commit() require.NoError(t, err) // execute a block, collect commit ID - res, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 2}) + res, err = app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 2}) require.NoError(t, err) commitID2 := storetypes.CommitID{Version: 2, Hash: res.AppHash} _, err = app.Commit() @@ -283,7 +283,7 @@ func TestLoadVersion(t *testing.T) { testLoadVersionHelper(t, app, int64(1), commitID1) - _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 2}) + _, err = app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 2}) require.NoError(t, err) _, err = app.Commit() require.NoError(t, err) @@ -371,7 +371,7 @@ func TestSetLoader(t *testing.T) { require.Nil(t, err) // "execute" one block - res, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 2}) + res, err := app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 2}) require.NoError(t, err) require.NotNil(t, res.AppHash) _, err = app.Commit() @@ -391,7 +391,7 @@ func TestVersionSetterGetter(t *testing.T) { app := baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil, pruningOpt) require.Equal(t, "", app.Version()) - res, err := app.Query(context.TODO(), &abci.RequestQuery{Path: "app/version"}) + res, err := app.Query(context.TODO(), &abci.QueryRequest{Path: "app/version"}) require.NoError(t, err) require.True(t, res.IsOK()) require.Equal(t, "", string(res.Value)) @@ -400,7 +400,7 @@ func TestVersionSetterGetter(t *testing.T) { app.SetVersion(versionString) require.Equal(t, versionString, app.Version()) - res, err = app.Query(context.TODO(), &abci.RequestQuery{Path: "app/version"}) + res, err = app.Query(context.TODO(), &abci.QueryRequest{Path: "app/version"}) require.NoError(t, err) require.True(t, res.IsOK()) require.Equal(t, versionString, string(res.Value)) @@ -420,7 +420,7 @@ func TestLoadVersionInvalid(t *testing.T) { err = app.LoadVersion(-1) require.Error(t, err) - res, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) + res, err := app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1}) require.NoError(t, err) commitID1 := storetypes.CommitID{Version: 1, Hash: res.AppHash} _, err = app.Commit() @@ -530,7 +530,7 @@ func TestCustomRunTxPanicHandler(t *testing.T) { suite := NewBaseAppSuite(t, anteOpt) baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), NoopCounterServerImpl{}) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{}, }) require.NoError(t, err) @@ -555,7 +555,7 @@ func TestCustomRunTxPanicHandler(t *testing.T) { require.PanicsWithValue(t, customPanicMsg, func() { bz, err := suite.txConfig.TxEncoder()(tx) require.NoError(t, err) - _, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1, Txs: [][]byte{bz}}) + _, err = suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1, Txs: [][]byte{bz}}) require.NoError(t, err) }) } @@ -571,7 +571,7 @@ func TestBaseAppAnteHandler(t *testing.T) { deliverKey := []byte("deliver-key") baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), CounterServerImpl{t, capKey1, deliverKey}) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{}, }) require.NoError(t, err) @@ -586,7 +586,7 @@ func TestBaseAppAnteHandler(t *testing.T) { txBytes, err := suite.txConfig.TxEncoder()(tx) require.NoError(t, err) - res, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1, Txs: [][]byte{txBytes}}) + res, err := suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1, Txs: [][]byte{txBytes}}) require.NoError(t, err) require.Empty(t, res.Events) require.False(t, res.TxResults[0].IsOK(), fmt.Sprintf("%v", res)) @@ -603,7 +603,7 @@ func TestBaseAppAnteHandler(t *testing.T) { txBytes, err = suite.txConfig.TxEncoder()(tx) require.NoError(t, err) - res, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1, Txs: [][]byte{txBytes}}) + res, err = suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1, Txs: [][]byte{txBytes}}) require.NoError(t, err) require.Empty(t, res.Events) require.False(t, res.TxResults[0].IsOK(), fmt.Sprintf("%v", res)) @@ -620,7 +620,7 @@ func TestBaseAppAnteHandler(t *testing.T) { txBytes, err = suite.txConfig.TxEncoder()(tx) require.NoError(t, err) - res, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1, Txs: [][]byte{txBytes}}) + res, err = suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1, Txs: [][]byte{txBytes}}) require.NoError(t, err) require.NotEmpty(t, res.TxResults[0].Events) require.True(t, res.TxResults[0].IsOK(), fmt.Sprintf("%v", res)) @@ -646,7 +646,7 @@ func TestBaseAppPostHandler(t *testing.T) { suite := NewBaseAppSuite(t, anteOpt) baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), CounterServerImpl{t, capKey1, []byte("foo")}) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &cmtproto.ConsensusParams{}, }) require.NoError(t, err) @@ -659,7 +659,7 @@ func TestBaseAppPostHandler(t *testing.T) { txBytes, err := suite.txConfig.TxEncoder()(tx) require.NoError(t, err) - res, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1, Txs: [][]byte{txBytes}}) + res, err := suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1, Txs: [][]byte{txBytes}}) require.NoError(t, err) require.Empty(t, res.Events) require.True(t, res.TxResults[0].IsOK(), fmt.Sprintf("%v", res)) @@ -672,7 +672,7 @@ func TestBaseAppPostHandler(t *testing.T) { tx = setFailOnHandler(t, suite.txConfig, tx, true) txBytes, err = suite.txConfig.TxEncoder()(tx) require.NoError(t, err) - res, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1, Txs: [][]byte{txBytes}}) + res, err = suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1, Txs: [][]byte{txBytes}}) require.NoError(t, err) require.Empty(t, res.Events) require.False(t, res.TxResults[0].IsOK(), fmt.Sprintf("%v", res)) @@ -683,7 +683,7 @@ func TestBaseAppPostHandler(t *testing.T) { tx = wonkyMsg(t, suite.txConfig, tx) txBytes, err = suite.txConfig.TxEncoder()(tx) require.NoError(t, err) - _, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1, Txs: [][]byte{txBytes}}) + _, err = suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1, Txs: [][]byte{txBytes}}) require.NoError(t, err) require.NotContains(t, suite.logBuffer.String(), "panic recovered in runTx") } @@ -699,12 +699,12 @@ func TestABCI_CreateQueryContext(t *testing.T) { name := t.Name() app := baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil) - _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) + _, err := app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1}) require.NoError(t, err) _, err = app.Commit() require.NoError(t, err) - _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 2}) + _, err = app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 2}) require.NoError(t, err) _, err = app.Commit() require.NoError(t, err) @@ -796,7 +796,7 @@ func TestQueryGasLimit(t *testing.T) { func TestGetMaximumBlockGas(t *testing.T) { suite := NewBaseAppSuite(t) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{}) + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{}) require.NoError(t, err) ctx := suite.baseApp.NewContext(true) @@ -819,7 +819,7 @@ func TestGetMaximumBlockGas(t *testing.T) { func TestGetEmptyConsensusParams(t *testing.T) { suite := NewBaseAppSuite(t) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{}) + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{}) require.NoError(t, err) ctx := suite.baseApp.NewContext(true) @@ -859,7 +859,7 @@ func TestLoadVersionPruning(t *testing.T) { // Commit seven blocks, of which 7 (latest) is kept in addition to 6, 5 // (keep recent) and 3 (keep every). for i := int64(1); i <= 7; i++ { - res, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: i}) + res, err := app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: i}) require.NoError(t, err) _, err = app.Commit() require.NoError(t, err) diff --git a/baseapp/grpcrouter_helpers.go b/baseapp/grpcrouter_helpers.go index 9f737e0e06f5..74f5eff9122a 100644 --- a/baseapp/grpcrouter_helpers.go +++ b/baseapp/grpcrouter_helpers.go @@ -45,7 +45,7 @@ func (q *QueryServiceTestHelper) Invoke(_ gocontext.Context, method string, args return err } - res, err := querier(q.Ctx, &abci.RequestQuery{Data: reqBz}) + res, err := querier(q.Ctx, &abci.QueryRequest{Data: reqBz}) if err != nil { return err } diff --git a/baseapp/oe/optimistic_execution_test.go b/baseapp/oe/optimistic_execution_test.go index 0b92244783cd..b7ec6b4fd801 100644 --- a/baseapp/oe/optimistic_execution_test.go +++ b/baseapp/oe/optimistic_execution_test.go @@ -11,14 +11,14 @@ import ( "cosmossdk.io/log" ) -func testFinalizeBlock(_ context.Context, _ *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) { +func testFinalizeBlock(_ context.Context, _ *abci.FinalizeBlockRequest) (*abci.FinalizeBlockResponse, error) { return nil, errors.New("test error") } func TestOptimisticExecution(t *testing.T) { oe := NewOptimisticExecution(log.NewNopLogger(), testFinalizeBlock) assert.True(t, oe.Enabled()) - oe.Execute(&abci.RequestProcessProposal{ + oe.Execute(&abci.ProcessProposalRequest{ Hash: []byte("test"), }) assert.True(t, oe.Initialized()) diff --git a/baseapp/snapshot_test.go b/baseapp/snapshot_test.go index 3051177e4788..7c7792e85559 100644 --- a/baseapp/snapshot_test.go +++ b/baseapp/snapshot_test.go @@ -23,7 +23,7 @@ func TestABCI_ListSnapshots(t *testing.T) { suite := NewBaseAppSuiteWithSnapshots(t, ssCfg) - resp, err := suite.baseApp.ListSnapshots(&abci.RequestListSnapshots{}) + resp, err := suite.baseApp.ListSnapshots(&abci.ListSnapshotsRequest{}) require.NoError(t, err) for _, s := range resp.Snapshots { require.NotEmpty(t, s.Hash) @@ -33,7 +33,7 @@ func TestABCI_ListSnapshots(t *testing.T) { s.Metadata = nil } - require.Equal(t, &abci.ResponseListSnapshots{Snapshots: []*abci.Snapshot{ + require.Equal(t, &abci.ListSnapshotsResponse{Snapshots: []*abci.Snapshot{ {Height: 4, Format: snapshottypes.CurrentFormat, Chunks: 2}, {Height: 2, Format: snapshottypes.CurrentFormat, Chunks: 1}, }}, resp) @@ -122,7 +122,7 @@ func TestABCI_SnapshotWithPruning(t *testing.T) { t.Run(name, func(t *testing.T) { suite := NewBaseAppSuiteWithSnapshots(t, tc.ssCfg) - resp, err := suite.baseApp.ListSnapshots(&abci.RequestListSnapshots{}) + resp, err := suite.baseApp.ListSnapshots(&abci.ListSnapshotsRequest{}) require.NoError(t, err) for _, s := range resp.Snapshots { require.NotEmpty(t, s.Hash) @@ -132,7 +132,7 @@ func TestABCI_SnapshotWithPruning(t *testing.T) { s.Metadata = nil } - require.Equal(t, &abci.ResponseListSnapshots{Snapshots: tc.expectedSnapshots}, resp) + require.Equal(t, &abci.ListSnapshotsResponse{Snapshots: tc.expectedSnapshots}, resp) // Validate that heights were pruned correctly by querying the state at the last height that should be present relative to latest // and the first height that should be pruned. @@ -150,13 +150,13 @@ func TestABCI_SnapshotWithPruning(t *testing.T) { } // Query 1 - res, err := suite.baseApp.Query(context.TODO(), &abci.RequestQuery{Path: fmt.Sprintf("/store/%s/key", capKey2.Name()), Data: []byte("0"), Height: lastExistingHeight}) + res, err := suite.baseApp.Query(context.TODO(), &abci.QueryRequest{Path: fmt.Sprintf("/store/%s/key", capKey2.Name()), Data: []byte("0"), Height: lastExistingHeight}) require.NoError(t, err) require.NotNil(t, res, "height: %d", lastExistingHeight) require.NotNil(t, res.Value, "height: %d", lastExistingHeight) // Query 2 - res, err = suite.baseApp.Query(context.TODO(), &abci.RequestQuery{Path: fmt.Sprintf("/store/%s/key", capKey2.Name()), Data: []byte("0"), Height: lastExistingHeight - 1}) + res, err = suite.baseApp.Query(context.TODO(), &abci.QueryRequest{Path: fmt.Sprintf("/store/%s/key", capKey2.Name()), Data: []byte("0"), Height: lastExistingHeight - 1}) require.NoError(t, err) require.NotNil(t, res, "height: %d", lastExistingHeight-1) @@ -195,13 +195,13 @@ func TestABCI_LoadSnapshotChunk(t *testing.T) { for name, tc := range testCases { t.Run(name, func(t *testing.T) { - resp, _ := suite.baseApp.LoadSnapshotChunk(&abci.RequestLoadSnapshotChunk{ + resp, _ := suite.baseApp.LoadSnapshotChunk(&abci.LoadSnapshotChunkRequest{ Height: tc.height, Format: tc.format, Chunk: tc.chunk, }) if tc.expectEmpty { - require.Equal(t, &abci.ResponseLoadSnapshotChunk{}, resp) + require.Equal(t, &abci.LoadSnapshotChunkResponse{}, resp) return } @@ -228,33 +228,33 @@ func TestABCI_OfferSnapshot_Errors(t *testing.T) { testCases := map[string]struct { snapshot *abci.Snapshot - result abci.ResponseOfferSnapshot_Result + result abci.OfferSnapshotResult }{ - "nil snapshot": {nil, abci.ResponseOfferSnapshot_REJECT}, + "nil snapshot": {nil, abci.OFFER_SNAPSHOT_RESULT_REJECT}, "invalid format": {&abci.Snapshot{ Height: 1, Format: 9, Chunks: 3, Hash: hash, Metadata: metadata, - }, abci.ResponseOfferSnapshot_REJECT_FORMAT}, + }, abci.OFFER_SNAPSHOT_RESULT_REJECT_FORMAT}, "incorrect chunk count": {&abci.Snapshot{ Height: 1, Format: snapshottypes.CurrentFormat, Chunks: 2, Hash: hash, Metadata: metadata, - }, abci.ResponseOfferSnapshot_REJECT}, + }, abci.OFFER_SNAPSHOT_RESULT_REJECT}, "no chunks": {&abci.Snapshot{ Height: 1, Format: snapshottypes.CurrentFormat, Chunks: 0, Hash: hash, Metadata: metadata, - }, abci.ResponseOfferSnapshot_REJECT}, + }, abci.OFFER_SNAPSHOT_RESULT_REJECT}, "invalid metadata serialization": {&abci.Snapshot{ Height: 1, Format: snapshottypes.CurrentFormat, Chunks: 0, Hash: hash, Metadata: []byte{3, 1, 4}, - }, abci.ResponseOfferSnapshot_REJECT}, + }, abci.OFFER_SNAPSHOT_RESULT_REJECT}, } for name, tc := range testCases { tc := tc t.Run(name, func(t *testing.T) { - resp, err := suite.baseApp.OfferSnapshot(&abci.RequestOfferSnapshot{Snapshot: tc.snapshot}) + resp, err := suite.baseApp.OfferSnapshot(&abci.OfferSnapshotRequest{Snapshot: tc.snapshot}) require.NoError(t, err) require.Equal(t, tc.result, resp.Result) }) } // Offering a snapshot after one has been accepted should error - resp, err := suite.baseApp.OfferSnapshot(&abci.RequestOfferSnapshot{Snapshot: &abci.Snapshot{ + resp, err := suite.baseApp.OfferSnapshot(&abci.OfferSnapshotRequest{Snapshot: &abci.Snapshot{ Height: 1, Format: snapshottypes.CurrentFormat, Chunks: 3, @@ -262,9 +262,9 @@ func TestABCI_OfferSnapshot_Errors(t *testing.T) { Metadata: metadata, }}) require.NoError(t, err) - require.Equal(t, &abci.ResponseOfferSnapshot{Result: abci.ResponseOfferSnapshot_ACCEPT}, resp) + require.Equal(t, &abci.OfferSnapshotResponse{Result: abci.OFFER_SNAPSHOT_RESULT_ACCEPT}, resp) - resp, err = suite.baseApp.OfferSnapshot(&abci.RequestOfferSnapshot{Snapshot: &abci.Snapshot{ + resp, err = suite.baseApp.OfferSnapshot(&abci.OfferSnapshotRequest{Snapshot: &abci.Snapshot{ Height: 2, Format: snapshottypes.CurrentFormat, Chunks: 3, @@ -272,7 +272,7 @@ func TestABCI_OfferSnapshot_Errors(t *testing.T) { Metadata: metadata, }}) require.NoError(t, err) - require.Equal(t, &abci.ResponseOfferSnapshot{Result: abci.ResponseOfferSnapshot_ABORT}, resp) + require.Equal(t, &abci.OfferSnapshotResponse{Result: abci.OFFER_SNAPSHOT_RESULT_ABORT}, resp) } func TestABCI_ApplySnapshotChunk(t *testing.T) { @@ -295,7 +295,7 @@ func TestABCI_ApplySnapshotChunk(t *testing.T) { targetSuite := NewBaseAppSuiteWithSnapshots(t, targetCfg) // fetch latest snapshot to restore - respList, err := srcSuite.baseApp.ListSnapshots(&abci.RequestListSnapshots{}) + respList, err := srcSuite.baseApp.ListSnapshots(&abci.ListSnapshotsRequest{}) require.NoError(t, err) require.NotEmpty(t, respList.Snapshots) snapshot := respList.Snapshots[0] @@ -304,27 +304,27 @@ func TestABCI_ApplySnapshotChunk(t *testing.T) { require.GreaterOrEqual(t, snapshot.Chunks, uint32(3), "Not enough snapshot chunks") // begin a snapshot restoration in the target - respOffer, err := targetSuite.baseApp.OfferSnapshot(&abci.RequestOfferSnapshot{Snapshot: snapshot}) + respOffer, err := targetSuite.baseApp.OfferSnapshot(&abci.OfferSnapshotRequest{Snapshot: snapshot}) require.NoError(t, err) - require.Equal(t, &abci.ResponseOfferSnapshot{Result: abci.ResponseOfferSnapshot_ACCEPT}, respOffer) + require.Equal(t, &abci.OfferSnapshotResponse{Result: abci.OFFER_SNAPSHOT_RESULT_ACCEPT}, respOffer) // We should be able to pass an invalid chunk and get a verify failure, before // reapplying it. - respApply, err := targetSuite.baseApp.ApplySnapshotChunk(&abci.RequestApplySnapshotChunk{ + respApply, err := targetSuite.baseApp.ApplySnapshotChunk(&abci.ApplySnapshotChunkRequest{ Index: 0, Chunk: []byte{9}, Sender: "sender", }) require.NoError(t, err) - require.Equal(t, &abci.ResponseApplySnapshotChunk{ - Result: abci.ResponseApplySnapshotChunk_RETRY, + require.Equal(t, &abci.ApplySnapshotChunkResponse{ + Result: abci.APPLY_SNAPSHOT_CHUNK_RESULT_RETRY, RefetchChunks: []uint32{0}, RejectSenders: []string{"sender"}, }, respApply) // fetch each chunk from the source and apply it to the target for index := uint32(0); index < snapshot.Chunks; index++ { - respChunk, err := srcSuite.baseApp.LoadSnapshotChunk(&abci.RequestLoadSnapshotChunk{ + respChunk, err := srcSuite.baseApp.LoadSnapshotChunk(&abci.LoadSnapshotChunkRequest{ Height: snapshot.Height, Format: snapshot.Format, Chunk: index, @@ -332,13 +332,13 @@ func TestABCI_ApplySnapshotChunk(t *testing.T) { require.NoError(t, err) require.NotNil(t, respChunk.Chunk) - respApply, err := targetSuite.baseApp.ApplySnapshotChunk(&abci.RequestApplySnapshotChunk{ + respApply, err := targetSuite.baseApp.ApplySnapshotChunk(&abci.ApplySnapshotChunkRequest{ Index: index, Chunk: respChunk.Chunk, }) require.NoError(t, err) - require.Equal(t, &abci.ResponseApplySnapshotChunk{ - Result: abci.ResponseApplySnapshotChunk_ACCEPT, + require.Equal(t, &abci.ApplySnapshotChunkResponse{ + Result: abci.APPLY_SNAPSHOT_CHUNK_RESULT_ACCEPT, }, respApply) } diff --git a/baseapp/streaming_test.go b/baseapp/streaming_test.go index 47372ec6e6f5..9c8a41a38135 100644 --- a/baseapp/streaming_test.go +++ b/baseapp/streaming_test.go @@ -29,11 +29,11 @@ func NewMockABCIListener(name string) MockABCIListener { } } -func (m MockABCIListener) ListenFinalizeBlock(_ context.Context, _ abci.RequestFinalizeBlock, _ abci.ResponseFinalizeBlock) error { +func (m MockABCIListener) ListenFinalizeBlock(_ context.Context, _ abci.FinalizeBlockRequest, _ abci.FinalizeBlockResponse) error { return nil } -func (m *MockABCIListener) ListenCommit(_ context.Context, _ abci.ResponseCommit, cs []*storetypes.StoreKVPair) error { +func (m *MockABCIListener) ListenCommit(_ context.Context, _ abci.CommitResponse, cs []*storetypes.StoreKVPair) error { m.ChangeSet = cs return nil } @@ -52,7 +52,7 @@ func TestABCI_MultiListener_StateChanges(t *testing.T) { suite := NewBaseAppSuite(t, anteOpt, distOpt, streamingManagerOpt, addListenerOpt) _, err := suite.baseApp.InitChain( - &abci.RequestInitChain{ + &abci.InitChainRequest{ ConsensusParams: &tmproto.ConsensusParams{}, }, ) @@ -69,7 +69,7 @@ func TestABCI_MultiListener_StateChanges(t *testing.T) { var expectedChangeSet []*storetypes.StoreKVPair // create final block context state - _, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: int64(blockN) + 1, Txs: txs}) + _, err := suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{Height: int64(blockN) + 1, Txs: txs}) require.NoError(t, err) for i := 0; i < txPerHeight; i++ { @@ -94,7 +94,7 @@ func TestABCI_MultiListener_StateChanges(t *testing.T) { txs = append(txs, txBytes) } - res, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: int64(blockN) + 1, Txs: txs}) + res, err := suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{Height: int64(blockN) + 1, Txs: txs}) require.NoError(t, err) for _, tx := range res.TxResults { events := tx.GetEvents() @@ -119,7 +119,7 @@ func Test_Ctx_with_StreamingManager(t *testing.T) { addListenerOpt := func(bapp *baseapp.BaseApp) { bapp.CommitMultiStore().AddListeners([]storetypes.StoreKey{distKey1}) } suite := NewBaseAppSuite(t, streamingManagerOpt, addListenerOpt) - _, err := suite.baseApp.InitChain(&abci.RequestInitChain{ + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ ConsensusParams: &tmproto.ConsensusParams{}, }) require.NoError(t, err) @@ -134,7 +134,7 @@ func Test_Ctx_with_StreamingManager(t *testing.T) { for blockN := 0; blockN < nBlocks; blockN++ { - _, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: int64(blockN) + 1}) + _, err = suite.baseApp.FinalizeBlock(&abci.FinalizeBlockRequest{Height: int64(blockN) + 1}) require.NoError(t, err) ctx := getFinalizeBlockStateCtx(suite.baseApp) sm := ctx.StreamingManager() diff --git a/docs/architecture/adr-040-storage-and-smt-state-commitments.md b/docs/architecture/adr-040-storage-and-smt-state-commitments.md index 03bcb7819920..8ca8952bfea9 100644 --- a/docs/architecture/adr-040-storage-and-smt-state-commitments.md +++ b/docs/architecture/adr-040-storage-and-smt-state-commitments.md @@ -92,7 +92,7 @@ A new database snapshot will be created in every `EndBlocker` and identified by NOTE: `Commit` must be called exactly once per block. Otherwise we risk going out of sync for the version number and block height. NOTE: For the Cosmos SDK storage, we may consider splitting that interface into `Committer` and `PruningCommitter` - only the multiroot should implement `PruningCommitter` (cache and prefix store don't need pruning). -Number of historical versions for `abci.RequestQuery` and state sync snapshots is part of a node configuration, not a chain configuration (configuration implied by the blockchain consensus). A configuration should allow to specify number of past blocks and number of past blocks modulo some number (eg: 100 past blocks and one snapshot every 100 blocks for past 2000 blocks). Archival nodes can keep all past versions. +Number of historical versions for `abci.QueryRequest` and state sync snapshots is part of a node configuration, not a chain configuration (configuration implied by the blockchain consensus). A configuration should allow to specify number of past blocks and number of past blocks modulo some number (eg: 100 past blocks and one snapshot every 100 blocks for past 2000 blocks). Archival nodes can keep all past versions. Pruning old snapshots is effectively done by a database. Whenever we update a record in `SC`, SMT won't update nodes - instead it creates new nodes on the update path, without removing the old one. Since we are snapshotting each block, we need to change that mechanism to immediately remove orphaned nodes from the database. This is a safe operation - snapshots will keep track of the records and make it available when accessing past versions. @@ -100,8 +100,8 @@ To manage the active snapshots we will either use a DB _max number of snapshots_ #### Accessing old state versions -One of the functional requirements is to access old state. This is done through `abci.RequestQuery` structure. The version is specified by a block height (so we query for an object by a key `K` at block height `H`). The number of old versions supported for `abci.RequestQuery` is configurable. Accessing an old state is done by using available snapshots. -`abci.RequestQuery` doesn't need old state of `SC` unless the `prove=true` parameter is set. The SMT merkle proof must be included in the `abci.ResponseQuery` only if both `SC` and `SS` have a snapshot for requested version. +One of the functional requirements is to access old state. This is done through `abci.QueryRequest` structure. The version is specified by a block height (so we query for an object by a key `K` at block height `H`). The number of old versions supported for `abci.QueryRequest` is configurable. Accessing an old state is done by using available snapshots. +`abci.QueryRequest` doesn't need old state of `SC` unless the `prove=true` parameter is set. The SMT merkle proof must be included in the `abci.QueryResponse` only if both `SC` and `SS` have a snapshot for requested version. Moreover, Cosmos SDK could provide a way to directly access a historical state. However, a state machine shouldn't do that - since the number of snapshots is configurable, it would lead to nondeterministic execution. diff --git a/docs/architecture/adr-060-abci-1.0.md b/docs/architecture/adr-060-abci-1.0.md index 3f29be784e31..d2d93a89e2c1 100644 --- a/docs/architecture/adr-060-abci-1.0.md +++ b/docs/architecture/adr-060-abci-1.0.md @@ -169,7 +169,7 @@ Instead, we will define an additional ABCI interface method on the existing or `EndBlock`. This new interface method will be defined as follows: ```go -ProcessProposal(sdk.Context, abci.RequestProcessProposal) error {} +ProcessProposal(sdk.Context, abci.ProcessProposalRequest) error {} ``` Note, we must call `ProcessProposal` with a new internal branched state on the diff --git a/docs/architecture/adr-064-abci-2.0.md b/docs/architecture/adr-064-abci-2.0.md index 80383f83d5d2..fd6085368da2 100644 --- a/docs/architecture/adr-064-abci-2.0.md +++ b/docs/architecture/adr-064-abci-2.0.md @@ -103,7 +103,7 @@ vote extensions. We propose the following new handlers for applications to implement: ```go -type ExtendVoteHandler func(sdk.Context, abci.RequestExtendVote) abci.ResponseExtendVote +type ExtendVoteHandler func(sdk.Context, abci.ExtendVoteRequest) abci.ExtendVoteResponse type VerifyVoteExtensionHandler func(sdk.Context, abci.RequestVerifyVoteExtension) abci.ResponseVerifyVoteExtension ``` @@ -144,7 +144,7 @@ type VoteExtensionHandler struct { // ExtendVoteHandler can do something with h.mk and possibly h.state to create // a vote extension, such as fetching a series of prices for supported assets. -func (h VoteExtensionHandler) ExtendVoteHandler(ctx sdk.Context, req abci.RequestExtendVote) abci.ResponseExtendVote { +func (h VoteExtensionHandler) ExtendVoteHandler(ctx sdk.Context, req abci.ExtendVoteRequest) abci.ExtendVoteResponse { prices := GetPrices(ctx, h.mk.Assets()) bz, err := EncodePrices(h.cdc, prices) if err != nil { @@ -156,7 +156,7 @@ func (h VoteExtensionHandler) ExtendVoteHandler(ctx sdk.Context, req abci.Reques // NOTE: Vote extensions can be overridden since we can timeout in a round. SetPrices(h.state, req, bz) - return abci.ResponseExtendVote{VoteExtension: bz} + return abci.ExtendVoteResponse{VoteExtension: bz} } // VerifyVoteExtensionHandler can do something with h.state and req to verify diff --git a/docs/architecture/adr-067-simulator-v2.md b/docs/architecture/adr-067-simulator-v2.md index ae27f01e24bb..ba3be122979e 100644 --- a/docs/architecture/adr-067-simulator-v2.md +++ b/docs/architecture/adr-067-simulator-v2.md @@ -118,10 +118,10 @@ func (s *Simulator) SimulateBlock() { rProposer := s.SelectRandomProposer() rTxs := s.SelectTxs() - prepareResp, err := s.app.PrepareProposal(&abci.RequestPrepareProposal{Txs: rTxs}) + prepareResp, err := s.app.PrepareProposal(&abci.PrepareProposalRequest{Txs: rTxs}) // handle error - processResp, err := s.app.ProcessProposal(&abci.RequestProcessProposal{ + processResp, err := s.app.ProcessProposal(&abci.ProcessProposalRequest{ Txs: prepareResp.Txs, // ... }) diff --git a/docs/build/abci/03-vote-extensions.md b/docs/build/abci/03-vote-extensions.md index 6ce737f4d5a9..b6993494b37d 100644 --- a/docs/build/abci/03-vote-extensions.md +++ b/docs/build/abci/03-vote-extensions.md @@ -11,7 +11,7 @@ ABCI2.0 (colloquially called ABCI++) allows an application to extend a pre-commi validator process. The Cosmos SDK defines [`baseapp.ExtendVoteHandler`](https://github.com/cosmos/cosmos-sdk/blob/v0.50.1/types/abci.go#L26-L27): ```go -type ExtendVoteHandler func(Context, *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) +type ExtendVoteHandler func(Context, *abci.ExtendVoteRequest) (*abci.ExtendVoteResponse, error) ``` An application can set this handler in `app.go` via the `baseapp.SetExtendVoteHandler` diff --git a/docs/build/building-modules/01-module-manager.md b/docs/build/building-modules/01-module-manager.md index bce8cea7f6dc..56868af4a746 100644 --- a/docs/build/building-modules/01-module-manager.md +++ b/docs/build/building-modules/01-module-manager.md @@ -272,7 +272,7 @@ The module manager is used throughout the application whenever an action on a co * `SetOrderMigrations(moduleNames ...string)`: Sets the order of migrations to be run. If not set then migrations will be run with an order defined in `DefaultMigrationsOrder`. * `RegisterInvariants(ir sdk.InvariantRegistry)`: Registers the [invariants](./07-invariants.md) of module implementing the `HasInvariants` interface. * `RegisterServices(cfg Configurator)`: Registers the services of modules implementing the `HasServices` interface. -* `InitGenesis(ctx context.Context, genesisData map[string]json.RawMessage)`: Calls the [`InitGenesis`](./08-genesis.md#initgenesis) function of each module when the application is first started, in the order defined in `OrderInitGenesis`. Returns an `abci.ResponseInitChain` to the underlying consensus engine, which can contain validator updates. +* `InitGenesis(ctx context.Context, genesisData map[string]json.RawMessage)`: Calls the [`InitGenesis`](./08-genesis.md#initgenesis) function of each module when the application is first started, in the order defined in `OrderInitGenesis`. Returns an `abci.InitChainResponse` to the underlying consensus engine, which can contain validator updates. * `ExportGenesis(ctx context.Context)`: Calls the [`ExportGenesis`](./08-genesis.md#exportgenesis) function of each module, in the order defined in `OrderExportGenesis`. The export constructs a genesis file from a previously existing state, and is mainly used when a hard-fork upgrade of the chain is required. * `ExportGenesisForModules(ctx context.Context, modulesToExport []string)`: Behaves the same as `ExportGenesis`, except takes a list of modules to export. * `BeginBlock(ctx context.Context) error`: At the beginning of each block, this function is called from [`BaseApp`](../../learn/advanced/00-baseapp.md#beginblock) and, in turn, calls the [`BeginBlock`](./06-beginblock-endblock.md) function of each modules implementing the `appmodule.HasBeginBlocker` interface, in the order defined in `OrderBeginBlockers`. It creates a child [context](../../learn/advanced/02-context.md) with an event manager to aggregate [events](../../learn/advanced/08-events.md) emitted from each modules. diff --git a/docs/build/building-modules/02-messages-and-queries.md b/docs/build/building-modules/02-messages-and-queries.md index 0751c96d6c9b..5c97401b91df 100644 --- a/docs/build/building-modules/02-messages-and-queries.md +++ b/docs/build/building-modules/02-messages-and-queries.md @@ -128,7 +128,7 @@ The `path` for each `query` must be defined by the module developer in the modul ### Store Queries -Store queries query directly for store keys. They use `clientCtx.QueryABCI(req abci.RequestQuery)` to return the full `abci.ResponseQuery` with inclusion Merkle proofs. +Store queries query directly for store keys. They use `clientCtx.QueryABCI(req abci.QueryRequest)` to return the full `abci.QueryResponse` with inclusion Merkle proofs. See following examples: diff --git a/docs/learn/advanced/00-baseapp.md b/docs/learn/advanced/00-baseapp.md index d4d31ed50f17..6760c12b5145 100644 --- a/docs/learn/advanced/00-baseapp.md +++ b/docs/learn/advanced/00-baseapp.md @@ -264,7 +264,7 @@ Note that, unlike `CheckTx()`, `PrepareProposal` process `sdk.Msg`s, so it can d It's important to note that `PrepareProposal` complements the `ProcessProposal` method which is executed after this method. The combination of these two methods means that it is possible to guarantee that no invalid transactions are ever committed. Furthermore, such a setup can give rise to other interesting use cases such as Oracles, threshold decryption and more. -`PrepareProposal` returns a response to the underlying consensus engine of type [`abci.ResponseCheckTx`](https://github.com/cometbft/cometbft/blob/v0.37.x/spec/abci/abci++_methods.md#processproposal). The response contains: +`PrepareProposal` returns a response to the underlying consensus engine of type [`abci.CheckTxResponse`](https://github.com/cometbft/cometbft/blob/v0.37.x/spec/abci/abci++_methods.md#processproposal). The response contains: * `Code (uint32)`: Response Code. `0` if successful. * `Data ([]byte)`: Result bytes, if any. @@ -291,7 +291,7 @@ CometBFT calls it when it receives a proposal and the CometBFT algorithm has not However, developers must exercise greater caution when using these methods. Incorrectly coding these methods could affect liveness as CometBFT is unable to receive 2/3 valid precommits to finalize a block. -`ProcessProposal` returns a response to the underlying consensus engine of type [`abci.ResponseCheckTx`](https://github.com/cometbft/cometbft/blob/v0.37.x/spec/abci/abci++_methods.md#processproposal). The response contains: +`ProcessProposal` returns a response to the underlying consensus engine of type [`abci.CheckTxResponse`](https://github.com/cometbft/cometbft/blob/v0.37.x/spec/abci/abci++_methods.md#processproposal). The response contains: * `Code (uint32)`: Response Code. `0` if successful. * `Data ([]byte)`: Result bytes, if any. @@ -338,7 +338,7 @@ be rejected. In any case, the sender's account will not actually pay the fees un is actually included in a block, because `checkState` never gets committed to the main state. The `checkState` is reset to the latest state of the main state each time a blocks gets [committed](#commit). -`CheckTx` returns a response to the underlying consensus engine of type [`abci.ResponseCheckTx`](https://github.com/cometbft/cometbft/blob/v0.37.x/spec/abci/abci++_methods.md#checktx). +`CheckTx` returns a response to the underlying consensus engine of type [`abci.CheckTxResponse`](https://github.com/cometbft/cometbft/blob/v0.37.x/spec/abci/abci++_methods.md#checktx). The response contains: * `Code (uint32)`: Response Code. `0` if successful. @@ -514,13 +514,13 @@ Finally, `Commit` returns the hash of the commitment of `app.cms` back to the un ### Info -The [`Info` ABCI message](https://github.com/cometbft/cometbft/blob/v0.37.x/spec/abci/abci++_basic_concepts.md#info-methods) is a simple query from the underlying consensus engine, notably used to sync the latter with the application during a handshake that happens on startup. When called, the `Info(res abci.ResponseInfo)` function from `BaseApp` will return the application's name, version and the hash of the last commit of `app.cms`. +The [`Info` ABCI message](https://github.com/cometbft/cometbft/blob/v0.37.x/spec/abci/abci++_basic_concepts.md#info-methods) is a simple query from the underlying consensus engine, notably used to sync the latter with the application during a handshake that happens on startup. When called, the `Info(res abci.InfoResponse)` function from `BaseApp` will return the application's name, version and the hash of the last commit of `app.cms`. ### Query The [`Query` ABCI message](https://github.com/cometbft/cometbft/blob/v0.37.x/spec/abci/abci++_basic_concepts.md#info-methods) is used to serve queries received from the underlying consensus engine, including queries received via RPC like CometBFT RPC. It used to be the main entrypoint to build interfaces with the application, but with the introduction of [gRPC queries](../../build/building-modules/04-query-services.md) in Cosmos SDK v0.40, its usage is more limited. The application must respect a few rules when implementing the `Query` method, which are outlined [here](https://github.com/cometbft/cometbft/blob/v0.37.x/spec/abci/abci++_app_requirements.md#query). -Each CometBFT `query` comes with a `path`, which is a `string` which denotes what to query. If the `path` matches a gRPC fully-qualified service method, then `BaseApp` will defer the query to the `grpcQueryRouter` and let it handle it like explained [above](#grpc-query-router). Otherwise, the `path` represents a query that is not (yet) handled by the gRPC router. `BaseApp` splits the `path` string with the `/` delimiter. By convention, the first element of the split string (`split[0]`) contains the category of `query` (`app`, `p2p`, `store` or `custom` ). The `BaseApp` implementation of the `Query(req abci.RequestQuery)` method is a simple dispatcher serving these 4 main categories of queries: +Each CometBFT `query` comes with a `path`, which is a `string` which denotes what to query. If the `path` matches a gRPC fully-qualified service method, then `BaseApp` will defer the query to the `grpcQueryRouter` and let it handle it like explained [above](#grpc-query-router). Otherwise, the `path` represents a query that is not (yet) handled by the gRPC router. `BaseApp` splits the `path` string with the `/` delimiter. By convention, the first element of the split string (`split[0]`) contains the category of `query` (`app`, `p2p`, `store` or `custom` ). The `BaseApp` implementation of the `Query(req abci.QueryRequest)` method is a simple dispatcher serving these 4 main categories of queries: * Application-related queries like querying the application's version, which are served via the `handleQueryApp` method. * Direct queries to the multistore, which are served by the `handlerQueryStore` method. These direct queries are different from custom queries which go through `app.queryRouter`, and are mainly used by third-party service provider like block explorers. diff --git a/docs/learn/advanced/15-upgrade.md b/docs/learn/advanced/15-upgrade.md index 5d56f2b59605..8106970773d2 100644 --- a/docs/learn/advanced/15-upgrade.md +++ b/docs/learn/advanced/15-upgrade.md @@ -103,7 +103,7 @@ if upgradeInfo.Name == "my-plan" && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo. When starting a new chain, the consensus version of each module MUST be saved to state during the application's genesis. To save the consensus version, add the following line to the `InitChainer` method in `app.go`: ```diff -func (app *MyApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { +func (app *MyApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.InitChainResponse { ... + app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap()) ... diff --git a/docs/learn/beginner/01-tx-lifecycle.md b/docs/learn/beginner/01-tx-lifecycle.md index 949add247e42..132042cb161c 100644 --- a/docs/learn/beginner/01-tx-lifecycle.md +++ b/docs/learn/beginner/01-tx-lifecycle.md @@ -56,7 +56,7 @@ The command-line is an easy way to interact with an application, but `Tx` can al ## Addition to Mempool Each full-node (running CometBFT) that receives a `Tx` sends an [ABCI message](https://docs.cometbft.com/v0.38/spec/p2p/legacy-docs/messages/), -`CheckTx`, to the application layer to check for validity, and receives an `abci.ResponseCheckTx`. If the `Tx` passes the checks, it is held in the node's +`CheckTx`, to the application layer to check for validity, and receives an `abci.CheckTxResponse`. If the `Tx` passes the checks, it is held in the node's [**Mempool**](https://docs.cometbft.com/v0.37/spec/p2p/legacy-docs/messages/mempool/), an in-memory pool of transactions unique to each node, pending inclusion in a block - honest nodes discard a `Tx` if it is found to be invalid. Prior to consensus, nodes continuously check incoming transactions and gossip them to their peers. ### Types of Checks diff --git a/docs/learn/beginner/02-query-lifecycle.md b/docs/learn/beginner/02-query-lifecycle.md index 0eda8d988d10..153af6f5c0d8 100644 --- a/docs/learn/beginner/02-query-lifecycle.md +++ b/docs/learn/beginner/02-query-lifecycle.md @@ -134,7 +134,7 @@ Once a result is received from the querier, `baseapp` begins the process of retu ## Response -Since `Query()` is an ABCI function, `baseapp` returns the response as an [`abci.ResponseQuery`](https://docs.cometbft.com/v0.38/spec/abci/abci++_app_requirements#query) type. The `client.Context` `Query()` routine receives the response. +Since `Query()` is an ABCI function, `baseapp` returns the response as an [`abci.QueryResponse`](https://docs.cometbft.com/v0.38/spec/abci/abci++_app_requirements#query) type. The `client.Context` `Query()` routine receives the response. ### CLI Response diff --git a/docs/spec/store/README.md b/docs/spec/store/README.md index bd665aa49996..706ee4d6c8a1 100644 --- a/docs/spec/store/README.md +++ b/docs/spec/store/README.md @@ -156,7 +156,7 @@ state from each `KVStore` to disk and returning an application state Merkle root Queries can be performed to return state data along with associated state commitment proofs for both previous heights/versions and the current state root. Queries are routed based on store name, i.e. a module, along with other parameters -which are defined in `abci.RequestQuery`. +which are defined in `abci.QueryRequest`. The `rootmulti.Store` also provides primitives for pruning data at a given height/version from state storage. When a height is committed, the `rootmulti.Store` diff --git a/server/cmt_abci.go b/server/cmt_abci.go index 65bb89bdc978..865523233d1b 100644 --- a/server/cmt_abci.go +++ b/server/cmt_abci.go @@ -28,7 +28,7 @@ func (w cometABCIWrapper) CheckTx(_ context.Context, req *abci.CheckTxRequest) ( return w.app.CheckTx(req) } -func (w cometABCIWrapper) InitChain(_ context.Context, req *abci.InitChainRequest) (*abci.InitChainRequest, error) { +func (w cometABCIWrapper) InitChain(_ context.Context, req *abci.InitChainRequest) (*abci.InitChainResponse, error) { return w.app.InitChain(req) } diff --git a/server/mock/app.go b/server/mock/app.go index 5348215355a9..2b2cb3960e0e 100644 --- a/server/mock/app.go +++ b/server/mock/app.go @@ -102,21 +102,21 @@ type GenesisJSON struct { // InitChainer returns a function that can initialize the chain // with key/value pairs -func InitChainer(key storetypes.StoreKey) func(sdk.Context, *abci.RequestInitChain) (*abci.ResponseInitChain, error) { - return func(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { +func InitChainer(key storetypes.StoreKey) func(sdk.Context, *abci.InitChainRequest) (*abci.InitChainResponse, error) { + return func(ctx sdk.Context, req *abci.InitChainRequest) (*abci.InitChainResponse, error) { stateJSON := req.AppStateBytes genesisState := new(GenesisJSON) err := json.Unmarshal(stateJSON, genesisState) if err != nil { - return &abci.ResponseInitChain{}, err + return &abci.InitChainResponse{}, err } for _, val := range genesisState.Values { store := ctx.KVStore(key) store.Set([]byte(val.Key), []byte(val.Value)) } - return &abci.ResponseInitChain{}, nil + return &abci.InitChainResponse{}, nil } } diff --git a/server/mock/app_test.go b/server/mock/app_test.go index 57496e33baeb..24cff78820c2 100644 --- a/server/mock/app_test.go +++ b/server/mock/app_test.go @@ -52,7 +52,7 @@ func TestInitApp(t *testing.T) { require.NoError(t, err) // make sure we can query these values - query := abci.RequestQuery{ + query := abci.QueryRequest{ Path: "/store/main/key", Data: []byte("foo"), } @@ -87,7 +87,7 @@ func TestDeliverTx(t *testing.T) { require.NoError(t, err) // make sure we can query these values - query := abci.RequestQuery{ + query := abci.QueryRequest{ Path: "/store/main/key", Data: []byte(key), } diff --git a/server/types/abci.go b/server/types/abci.go index 6eb922b9798e..456375eb2aac 100644 --- a/server/types/abci.go +++ b/server/types/abci.go @@ -12,38 +12,38 @@ type ABCI interface { // Info/Query Connection // Info returns application info - Info(*abci.RequestInfo) (*abci.ResponseInfo, error) + Info(*abci.InfoRequest) (*abci.InfoResponse, error) // Query returns application state - Query(context.Context, *abci.RequestQuery) (*abci.ResponseQuery, error) + Query(context.Context, *abci.QueryRequest) (*abci.QueryResponse, error) // Mempool Connection // CheckTx validate a tx for the mempool - CheckTx(*abci.RequestCheckTx) (*abci.ResponseCheckTx, error) + CheckTx(*abci.CheckTxRequest) (*abci.CheckTxResponse, error) // Consensus Connection // InitChain Initialize blockchain w validators/other info from CometBFT - InitChain(*abci.RequestInitChain) (*abci.ResponseInitChain, error) - PrepareProposal(*abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) - ProcessProposal(*abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) + InitChain(*abci.InitChainRequest) (*abci.InitChainResponse, error) + PrepareProposal(*abci.PrepareProposalRequest) (*abci.PrepareProposalResponse, error) + ProcessProposal(*abci.ProcessProposalRequest) (*abci.ProcessProposalResponse, error) // FinalizeBlock deliver the decided block with its txs to the Application - FinalizeBlock(*abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) + FinalizeBlock(*abci.FinalizeBlockRequest) (*abci.FinalizeBlockResponse, error) // ExtendVote create application specific vote extension - ExtendVote(context.Context, *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) + ExtendVote(context.Context, *abci.ExtendVoteRequest) (*abci.ExtendVoteResponse, error) // VerifyVoteExtension verify application's vote extension data - VerifyVoteExtension(*abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) + VerifyVoteExtension(*abci.VerifyVoteExtensionRequest) (*abci.VerifyVoteExtensionResponse, error) // Commit the state and return the application Merkle root hash - Commit() (*abci.ResponseCommit, error) + Commit() (*abci.CommitResponse, error) // State Sync Connection // ListSnapshots list available snapshots - ListSnapshots(*abci.RequestListSnapshots) (*abci.ResponseListSnapshots, error) + ListSnapshots(*abci.ListSnapshotsRequest) (*abci.ListSnapshotsResponse, error) // OfferSnapshot offer a snapshot to the application - OfferSnapshot(*abci.RequestOfferSnapshot) (*abci.ResponseOfferSnapshot, error) + OfferSnapshot(*abci.OfferSnapshotRequest) (*abci.OfferSnapshotResponse, error) // LoadSnapshotChunk load a snapshot chunk - LoadSnapshotChunk(*abci.RequestLoadSnapshotChunk) (*abci.ResponseLoadSnapshotChunk, error) + LoadSnapshotChunk(*abci.LoadSnapshotChunkRequest) (*abci.LoadSnapshotChunkResponse, error) // ApplySnapshotChunk apply a snapshot chunk - ApplySnapshotChunk(*abci.RequestApplySnapshotChunk) (*abci.ResponseApplySnapshotChunk, error) + ApplySnapshotChunk(*abci.ApplySnapshotChunkRequest) (*abci.ApplySnapshotChunkResponse, error) } diff --git a/simapp/abci.go b/simapp/abci.go index 7848d254d50f..eae537408f92 100644 --- a/simapp/abci.go +++ b/simapp/abci.go @@ -37,7 +37,7 @@ func (h *VoteExtensionHandler) SetHandlers(bApp *baseapp.BaseApp) { } func (h *VoteExtensionHandler) ExtendVote() sdk.ExtendVoteHandler { - return func(_ sdk.Context, req *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) { + return func(_ sdk.Context, req *abci.ExtendVoteRequest) (*abci.ExtendVoteResponse, error) { buf := make([]byte, 1024) _, err := rand.Read(buf) @@ -56,7 +56,7 @@ func (h *VoteExtensionHandler) ExtendVote() sdk.ExtendVoteHandler { return nil, fmt.Errorf("failed to encode vote extension: %w", err) } - return &abci.ResponseExtendVote{VoteExtension: bz}, nil + return &abci.ExtendVoteResponse{VoteExtension: bz}, nil } } diff --git a/simapp/app.go b/simapp/app.go index bee3d1931335..ab84b0feadb8 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -658,7 +658,7 @@ func (a *SimApp) Configurator() module.Configurator { // nolint:staticcheck // S } // InitChainer application update at chain initialization -func (app *SimApp) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { +func (app *SimApp) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.InitChainResponse, error) { var genesisState GenesisState err := json.Unmarshal(req.AppStateBytes, &genesisState) if err != nil { diff --git a/simapp/app_di.go b/simapp/app_di.go index efaca0e3e21f..e84d2e1ce324 100644 --- a/simapp/app_di.go +++ b/simapp/app_di.go @@ -268,7 +268,7 @@ func NewSimApp( // However, when registering a module manually (i.e. that does not support app wiring), the module version map // must be set manually as follow. The upgrade module will de-duplicate the module version map. // - // app.SetInitChainer(func(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { + // app.SetInitChainer(func(ctx sdk.Context, req *abci.RequestInitChain) (*abci.InitChainResponse, error) { // app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()) // return app.App.InitChainer(ctx, req) // }) diff --git a/tests/integration/auth/client/cli/suite_test.go b/tests/integration/auth/client/cli/suite_test.go index 963a313045c5..15eeb31e4218 100644 --- a/tests/integration/auth/client/cli/suite_test.go +++ b/tests/integration/auth/client/cli/suite_test.go @@ -73,7 +73,7 @@ func (s *CLITestSuite) SetupSuite() { ctxGen := func() client.Context { bz, _ := s.encCfg.Codec.Marshal(&sdk.TxResponse{}) - c := clitestutil.NewMockCometRPC(abci.ResponseQuery{ + c := clitestutil.NewMockCometRPC(abci.QueryResponse{ Value: bz, }) return s.baseCtx.WithClient(c) diff --git a/tests/integration/distribution/cli_tx_test.go b/tests/integration/distribution/cli_tx_test.go index f7e6767558e8..222f7d8234fe 100644 --- a/tests/integration/distribution/cli_tx_test.go +++ b/tests/integration/distribution/cli_tx_test.go @@ -55,7 +55,7 @@ func (s *CLITestSuite) SetupSuite() { ctxGen := func() client.Context { bz, _ := s.encCfg.Codec.Marshal(&sdk.TxResponse{}) - c := clitestutil.NewMockCometRPC(abci.ResponseQuery{ + c := clitestutil.NewMockCometRPC(abci.QueryResponse{ Value: bz, }) return s.baseCtx.WithClient(c) diff --git a/testutil/cli/cmt_mocks.go b/testutil/cli/cmt_mocks.go index a03ea176060a..3bb35e2040fb 100644 --- a/testutil/cli/cmt_mocks.go +++ b/testutil/cli/cmt_mocks.go @@ -18,12 +18,12 @@ var _ client.CometRPC = (*MockCometRPC)(nil) type MockCometRPC struct { rpcclientmock.Client - responseQuery abci.ResponseQuery + responseQuery abci.QueryResponse } // NewMockCometRPC returns a mock CometBFT RPC implementation. // It is used for CLI testing. -func NewMockCometRPC(respQuery abci.ResponseQuery) MockCometRPC { +func NewMockCometRPC(respQuery abci.QueryResponse) MockCometRPC { return MockCometRPC{responseQuery: respQuery} } diff --git a/types/abci.go b/types/abci.go index 701772806d93..a650535d098f 100644 --- a/types/abci.go +++ b/types/abci.go @@ -5,7 +5,7 @@ import ( ) // InitChainer initializes application state at genesis -type InitChainer func(ctx Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) +type InitChainer func(ctx Context, req *abci.InitChainRequest) (*abci.InitChainResponse, error) // PrepareCheckStater runs code during commit after the block has been committed, and the `checkState` // has been branched for the new block. @@ -15,20 +15,20 @@ type PrepareCheckStater func(ctx Context) type Precommiter func(ctx Context) // PeerFilter responds to p2p filtering queries from Tendermint -type PeerFilter func(info string) *abci.ResponseQuery +type PeerFilter func(info string) *abci.QueryResponse // ProcessProposalHandler defines a function type alias for processing a proposer -type ProcessProposalHandler func(Context, *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) +type ProcessProposalHandler func(Context, *abci.ProcessProposalRequest) (*abci.ProcessProposalResponse, error) // PrepareProposalHandler defines a function type alias for preparing a proposal -type PrepareProposalHandler func(Context, *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) +type PrepareProposalHandler func(Context, *abci.PrepareProposalRequest) (*abci.PrepareProposalResponse, error) // ExtendVoteHandler defines a function type alias for extending a pre-commit vote. -type ExtendVoteHandler func(Context, *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) +type ExtendVoteHandler func(Context, *abci.ExtendVoteRequest) (*abci.ExtendVoteResponse, error) // VerifyVoteExtensionHandler defines a function type alias for verifying a // pre-commit vote extension. -type VerifyVoteExtensionHandler func(Context, *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) +type VerifyVoteExtensionHandler func(Context, *abci.VerifyVoteExtensionRequest) (*abci.VerifyVoteExtensionResponse, error) // PreBlocker runs code before the `BeginBlocker` and defines a function type alias for executing logic right // before FinalizeBlock is called (but after its context has been set up). It is @@ -36,7 +36,7 @@ type VerifyVoteExtensionHandler func(Context, *abci.RequestVerifyVoteExtension) // persist their results in state. // // Note: returning an error will make FinalizeBlock fail. -type PreBlocker func(Context, *abci.RequestFinalizeBlock) error +type PreBlocker func(Context, *abci.FinalizeBlockRequest) error // BeginBlocker defines a function type alias for executing application // business logic before transactions are executed. diff --git a/types/errors/abci.go b/types/errors/abci.go index 47accd62d847..8344f465cc02 100644 --- a/types/errors/abci.go +++ b/types/errors/abci.go @@ -8,9 +8,9 @@ import ( // ResponseCheckTxWithEvents returns an ABCI ResponseCheckTx object with fields filled in // from the given error, gas values and events. -func ResponseCheckTxWithEvents(err error, gw, gu uint64, events []abci.Event, debug bool) *abci.ResponseCheckTx { +func ResponseCheckTxWithEvents(err error, gw, gu uint64, events []abci.Event, debug bool) *abci.CheckTxResponse { space, code, log := errorsmod.ABCIInfo(err, debug) - return &abci.ResponseCheckTx{ + return &abci.CheckTxResponse{ Codespace: space, Code: code, Log: log, @@ -36,9 +36,9 @@ func ResponseExecTxResultWithEvents(err error, gw, gu uint64, events []abci.Even // QueryResult returns a ResponseQuery from an error. It will try to parse ABCI // info from the error. -func QueryResult(err error, debug bool) *abci.ResponseQuery { +func QueryResult(err error, debug bool) *abci.QueryResponse { space, code, log := errorsmod.ABCIInfo(err, debug) - return &abci.ResponseQuery{ + return &abci.QueryResponse{ Codespace: space, Code: code, Log: log, diff --git a/types/module/module.go b/types/module/module.go index dd9f95ef99b5..bb044eb51418 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -426,7 +426,7 @@ func (m *Manager) RegisterServices(cfg Configurator) error { // InitGenesis performs init genesis functionality for modules. Exactly one // module must return a non-empty validator set update to correctly initialize // the chain. -func (m *Manager) InitGenesis(ctx sdk.Context, genesisData map[string]json.RawMessage) (*abci.ResponseInitChain, error) { +func (m *Manager) InitGenesis(ctx sdk.Context, genesisData map[string]json.RawMessage) (*abci.InitChainResponse, error) { var validatorUpdates []ValidatorUpdate ctx.Logger().Info("initializing blockchain state from genesis.json") for _, moduleName := range m.OrderInitGenesis { @@ -441,30 +441,30 @@ func (m *Manager) InitGenesis(ctx sdk.Context, genesisData map[string]json.RawMe // core API genesis source, err := genesis.SourceFromRawJSON(genesisData[moduleName]) if err != nil { - return &abci.ResponseInitChain{}, err + return &abci.InitChainResponse{}, err } err = module.InitGenesis(ctx, source) if err != nil { - return &abci.ResponseInitChain{}, err + return &abci.InitChainResponse{}, err } } else if module, ok := mod.(HasGenesis); ok { ctx.Logger().Debug("running initialization for module", "module", moduleName) if err := module.InitGenesis(ctx, genesisData[moduleName]); err != nil { - return &abci.ResponseInitChain{}, err + return &abci.InitChainResponse{}, err } } else if module, ok := mod.(HasABCIGenesis); ok { ctx.Logger().Debug("running initialization for module", "module", moduleName) moduleValUpdates, err := module.InitGenesis(ctx, genesisData[moduleName]) if err != nil { - return &abci.ResponseInitChain{}, err + return &abci.InitChainResponse{}, err } // use these validator updates if provided, the module manager assumes // only one module will update the validator set if len(moduleValUpdates) > 0 { if len(validatorUpdates) > 0 { - return &abci.ResponseInitChain{}, errors.New("validator InitGenesis updates already set by a previous module") + return &abci.InitChainResponse{}, errors.New("validator InitGenesis updates already set by a previous module") } validatorUpdates = moduleValUpdates } @@ -473,7 +473,7 @@ func (m *Manager) InitGenesis(ctx sdk.Context, genesisData map[string]json.RawMe // a chain must initialize with a non-empty validator set if len(validatorUpdates) == 0 { - return &abci.ResponseInitChain{}, fmt.Errorf("validator set is empty after InitGenesis, please ensure at least one validator is initialized with a delegation greater than or equal to the DefaultPowerReduction (%d)", sdk.DefaultPowerReduction) + return &abci.InitChainResponse{}, fmt.Errorf("validator set is empty after InitGenesis, please ensure at least one validator is initialized with a delegation greater than or equal to the DefaultPowerReduction (%d)", sdk.DefaultPowerReduction) } cometValidatorUpdates := make([]abci.ValidatorUpdate, len(validatorUpdates)) @@ -500,7 +500,7 @@ func (m *Manager) InitGenesis(ctx sdk.Context, genesisData map[string]json.RawMe } } - return &abci.ResponseInitChain{ + return &abci.InitChainResponse{ Validators: cometValidatorUpdates, }, nil } diff --git a/x/auth/ante/testutil_test.go b/x/auth/ante/testutil_test.go index 1814e94f2b29..537b1b41cb4c 100644 --- a/x/auth/ante/testutil_test.go +++ b/x/auth/ante/testutil_test.go @@ -93,7 +93,7 @@ func SetupTestSuite(t *testing.T, isCheckTx bool) *AnteTestSuite { suite.clientCtx = client.Context{}. WithTxConfig(suite.encCfg.TxConfig). - WithClient(clitestutil.NewMockCometRPC(abci.ResponseQuery{})) + WithClient(clitestutil.NewMockCometRPC(abci.QueryResponse{})) anteHandler, err := ante.NewAnteHandler( ante.HandlerOptions{ diff --git a/x/authz/client/cli/tx_test.go b/x/authz/client/cli/tx_test.go index bdb963a102a2..a70a5fc0f4bc 100644 --- a/x/authz/client/cli/tx_test.go +++ b/x/authz/client/cli/tx_test.go @@ -71,7 +71,7 @@ func (s *CLITestSuite) SetupSuite() { ctxGen := func() client.Context { bz, _ := s.encCfg.Codec.Marshal(&sdk.TxResponse{}) - c := clitestutil.NewMockCometRPC(abci.ResponseQuery{ + c := clitestutil.NewMockCometRPC(abci.QueryResponse{ Value: bz, }) return s.baseCtx.WithClient(c) diff --git a/x/feegrant/client/cli/tx_test.go b/x/feegrant/client/cli/tx_test.go index 16f3bc8ae6fa..c8578cd35cf9 100644 --- a/x/feegrant/client/cli/tx_test.go +++ b/x/feegrant/client/cli/tx_test.go @@ -79,7 +79,7 @@ func (s *CLITestSuite) SetupSuite() { ctxGen := func() client.Context { bz, _ := s.encCfg.Codec.Marshal(&sdk.TxResponse{}) - c := clitestutil.NewMockCometRPC(abci.ResponseQuery{ + c := clitestutil.NewMockCometRPC(abci.QueryResponse{ Value: bz, }) diff --git a/x/genutil/client/cli/gentx_test.go b/x/genutil/client/cli/gentx_test.go index a4c698398805..fac78ec67721 100644 --- a/x/genutil/client/cli/gentx_test.go +++ b/x/genutil/client/cli/gentx_test.go @@ -56,7 +56,7 @@ func (s *CLITestSuite) SetupSuite() { ctxGen := func() client.Context { bz, _ := s.encCfg.Codec.Marshal(&sdk.TxResponse{}) - c := clitestutil.NewMockCometRPC(abci.ResponseQuery{ + c := clitestutil.NewMockCometRPC(abci.QueryResponse{ Value: bz, }) return s.baseCtx.WithClient(c) diff --git a/x/gov/client/cli/tx_test.go b/x/gov/client/cli/tx_test.go index 744f990653e1..46620dd80537 100644 --- a/x/gov/client/cli/tx_test.go +++ b/x/gov/client/cli/tx_test.go @@ -60,7 +60,7 @@ func (s *CLITestSuite) SetupSuite() { ctxGen := func() client.Context { bz, _ := s.encCfg.Codec.Marshal(&sdk.TxResponse{}) - c := clitestutil.NewMockCometRPC(abci.ResponseQuery{ + c := clitestutil.NewMockCometRPC(abci.QueryResponse{ Value: bz, }) return s.baseCtx.WithClient(c) diff --git a/x/group/client/cli/tx_test.go b/x/group/client/cli/tx_test.go index 8f68ad67908c..d820242113c4 100644 --- a/x/group/client/cli/tx_test.go +++ b/x/group/client/cli/tx_test.go @@ -77,7 +77,7 @@ func (s *CLITestSuite) SetupSuite() { ctxGen := func() client.Context { bz, _ := s.encCfg.Codec.Marshal(&sdk.TxResponse{}) - c := clitestutil.NewMockCometRPC(abci.ResponseQuery{ + c := clitestutil.NewMockCometRPC(abci.QueryResponse{ Value: bz, }) return s.baseCtx.WithClient(c) diff --git a/x/simulation/mock_cometbft.go b/x/simulation/mock_cometbft.go index cfbe83978f00..4912b1b56423 100644 --- a/x/simulation/mock_cometbft.go +++ b/x/simulation/mock_cometbft.go @@ -124,9 +124,9 @@ func RandomRequestFinalizeBlock( blockHeight int64, time time.Time, proposer []byte, -) *abci.RequestFinalizeBlock { +) *abci.FinalizeBlockRequest { if len(validators) == 0 { - return &abci.RequestFinalizeBlock{ + return &abci.FinalizeBlockRequest{ Height: blockHeight, Time: time, ProposerAddress: proposer, @@ -172,7 +172,7 @@ func RandomRequestFinalizeBlock( // return if no past times if len(pastTimes) == 0 { - return &abci.RequestFinalizeBlock{ + return &abci.FinalizeBlockRequest{ Height: blockHeight, Time: time, ProposerAddress: proposer, @@ -211,7 +211,7 @@ func RandomRequestFinalizeBlock( evidence = append(evidence, abci.Misbehavior{ - Type: abci.MisbehaviorType_DUPLICATE_VOTE, + Type: abci.MISBEHAVIOR_TYPE_DUPLICATE_VOTE, Validator: validator, Height: height, Time: misbehaviorTime, @@ -222,7 +222,7 @@ func RandomRequestFinalizeBlock( event("begin_block", "evidence", "ok") } - return &abci.RequestFinalizeBlock{ + return &abci.FinalizeBlockRequest{ Height: blockHeight, Time: time, ProposerAddress: proposer, diff --git a/x/simulation/simulate.go b/x/simulation/simulate.go index b46ef9f221e5..5a558e3f02ad 100644 --- a/x/simulation/simulate.go +++ b/x/simulation/simulate.go @@ -39,7 +39,7 @@ func initChain( } appState, accounts, chainID, genesisTimestamp := appStateFn(r, accounts, config) consensusParams := randomConsensusParams(r, appState, cdc, blockMaxGas) - req := abci.RequestInitChain{ + req := abci.InitChainRequest{ AppStateBytes: appState, ChainId: chainID, ConsensusParams: consensusParams, diff --git a/x/staking/client/cli/tx_test.go b/x/staking/client/cli/tx_test.go index 39d8957bc640..ba30f129c617 100644 --- a/x/staking/client/cli/tx_test.go +++ b/x/staking/client/cli/tx_test.go @@ -61,7 +61,7 @@ func (s *CLITestSuite) SetupSuite() { ctxGen := func() client.Context { bz, _ := s.encCfg.Codec.Marshal(&sdk.TxResponse{}) - c := clitestutil.NewMockCometRPC(abci.ResponseQuery{ + c := clitestutil.NewMockCometRPC(abci.QueryResponse{ Value: bz, }) return s.baseCtx.WithClient(c) diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index 3cef68aeb268..62593b239ca6 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -7,7 +7,6 @@ import ( "strings" "time" - abci "github.com/cometbft/cometbft/abci/types" cmtprotocrypto "github.com/cometbft/cometbft/api/cometbft/crypto/v1" "cosmossdk.io/core/address"