refactor! : bump comet to v1 (#19726)

Co-authored-by: yihuang <yi.codeplayer@gmail.com>
This commit is contained in:
Marko
2024-05-06 14:12:00 +00:00
committed by GitHub
co-authored by yihuang
parent 89ccbc13d1
commit 0dfb54e36a
224 changed files with 6638 additions and 5959 deletions
+70 -62
View File
@@ -9,7 +9,7 @@ import (
"github.com/cockroachdb/errors"
abci "github.com/cometbft/cometbft/abci/types"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
"github.com/cosmos/gogoproto/proto"
"google.golang.org/grpc/codes"
grpcstatus "google.golang.org/grpc/status"
@@ -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
@@ -596,9 +596,13 @@ func (app *BaseApp) ExtendVote(_ context.Context, req *abci.RequestExtendVote) (
// greater than VoteExtensionsEnableHeight. This defers from the check done
// in ValidateVoteExtensions and PrepareProposal in which we'll check for
// vote extensions on VoteExtensionsEnableHeight+1.
extsEnabled := cp.Abci != nil && req.Height >= cp.Abci.VoteExtensionsEnableHeight && cp.Abci.VoteExtensionsEnableHeight != 0
extsEnabled := cp.Feature != nil && req.Height >= cp.Feature.VoteExtensionsEnableHeight.Value && cp.Feature.VoteExtensionsEnableHeight.Value != 0
if !extsEnabled {
return nil, fmt.Errorf("vote extensions are not enabled; unexpected call to ExtendVote at height %d", req.Height)
// check abci params
extsEnabled = cp.Abci != nil && req.Height >= cp.Abci.VoteExtensionsEnableHeight && cp.Abci.VoteExtensionsEnableHeight != 0
if !extsEnabled {
return nil, fmt.Errorf("vote extensions are not enabled; unexpected call to ExtendVote at height %d", req.Height)
}
}
ctx = ctx.
@@ -629,7 +633,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 +647,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/v1.0/references/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")
}
@@ -666,9 +670,13 @@ func (app *BaseApp) VerifyVoteExtension(req *abci.RequestVerifyVoteExtension) (r
// Note: we verify votes extensions on VoteExtensionsEnableHeight+1. Check
// comment in ExtendVote and ValidateVoteExtensions for more details.
extsEnabled := cp.Abci != nil && req.Height >= cp.Abci.VoteExtensionsEnableHeight && cp.Abci.VoteExtensionsEnableHeight != 0
extsEnabled := cp.Feature.VoteExtensionsEnableHeight != nil && req.Height >= cp.Feature.VoteExtensionsEnableHeight.Value && cp.Feature.VoteExtensionsEnableHeight.Value != 0
if !extsEnabled {
return nil, fmt.Errorf("vote extensions are not enabled; unexpected call to VerifyVoteExtension at height %d", req.Height)
// check abci params
extsEnabled = cp.Abci != nil && req.Height >= cp.Abci.VoteExtensionsEnableHeight && cp.Abci.VoteExtensionsEnableHeight != 0
if !extsEnabled {
return nil, fmt.Errorf("vote extensions are not enabled; unexpected call to VerifyVoteExtension at height %d", req.Height)
}
}
// add a deferred recover handler in case verifyVoteExt panics
@@ -700,7 +708,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 +718,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 +861,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 +879,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 +943,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 +958,7 @@ func (app *BaseApp) Commit() (*abci.ResponseCommit, error) {
app.cms.Commit()
resp := &abci.ResponseCommit{
resp := &abci.CommitResponse{
RetainHeight: retainHeight,
}
@@ -1003,7 +1011,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 +1032,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 +1057,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 +1081,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 <addr|id> <parameter>"), app.trace)
}
var resp *abci.ResponseQuery
var resp *abci.QueryResponse
cmd, typ, arg := path[1], path[2], path[3]
switch cmd {
@@ -1119,21 +1127,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 +1159,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)
+215 -210
View File
File diff suppressed because it is too large Load Diff
+21 -18
View File
@@ -8,9 +8,9 @@ import (
"github.com/cockroachdb/errors"
abci "github.com/cometbft/cometbft/abci/types"
cmtprotocrypto "github.com/cometbft/cometbft/api/cometbft/crypto/v1"
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
cryptoenc "github.com/cometbft/cometbft/crypto/encoding"
cmtprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
cmttypes "github.com/cometbft/cometbft/types"
protoio "github.com/cosmos/gogoproto/io"
"github.com/cosmos/gogoproto/proto"
@@ -59,7 +59,10 @@ func ValidateVoteExtensions(
// Start checking vote extensions only **after** the vote extensions enable
// height, because when `currentHeight == VoteExtensionsEnableHeight`
// PrepareProposal doesn't get any vote extensions in its request.
extsEnabled := cp.Abci != nil && currentHeight > cp.Abci.VoteExtensionsEnableHeight && cp.Abci.VoteExtensionsEnableHeight != 0
extsEnabled := cp.Feature != nil && cp.Feature.VoteExtensionsEnableHeight != nil && currentHeight > cp.Feature.VoteExtensionsEnableHeight.Value && cp.Feature.VoteExtensionsEnableHeight.Value != 0
if !extsEnabled {
extsEnabled = cp.Abci != nil && currentHeight > cp.Abci.VoteExtensionsEnableHeight && cp.Abci.VoteExtensionsEnableHeight != 0
}
marshalDelimitedFn := func(msg proto.Message) ([]byte, error) {
var buf bytes.Buffer
if err := protoio.NewDelimitedWriter(&buf).WriteMsg(msg); err != nil {
@@ -247,7 +250,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 { // nolint:staticcheck // ignore linting error
maxBlockGas = uint64(b.MaxGas)
@@ -273,7 +276,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 +351,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 +374,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 +385,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 +395,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
}
}
+16 -15
View File
@@ -6,13 +6,14 @@ import (
"testing"
abci "github.com/cometbft/cometbft/abci/types"
cmtprotocrypto "github.com/cometbft/cometbft/api/cometbft/crypto/v1"
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
cmtsecp256k1 "github.com/cometbft/cometbft/crypto/secp256k1"
cmtprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
cmttypes "github.com/cometbft/cometbft/types"
dbm "github.com/cosmos/cosmos-db"
protoio "github.com/cosmos/gogoproto/io"
"github.com/cosmos/gogoproto/proto"
gogotypes "github.com/cosmos/gogoproto/types"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
@@ -98,8 +99,8 @@ func NewABCIUtilsTestSuite(t *testing.T) *ABCIUtilsTestSuite {
// create context
s.ctx = sdk.Context{}.WithConsensusParams(cmtproto.ConsensusParams{
Abci: &cmtproto.ABCIParams{
VoteExtensionsEnableHeight: 2,
Feature: &cmtproto.FeatureParams{
VoteExtensionsEnableHeight: &gogotypes.Int64Value{Value: 2},
},
}).WithBlockHeader(cmtproto.Header{
ChainID: chainID,
@@ -499,12 +500,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 +517,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 +525,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 +533,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 +545,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 +629,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 +644,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 +653,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 +663,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{},
+6 -6
View File
@@ -10,8 +10,8 @@ import (
"github.com/cockroachdb/errors"
abci "github.com/cometbft/cometbft/abci/types"
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
"github.com/cometbft/cometbft/crypto/tmhash"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/gogoproto/proto"
"golang.org/x/exp/maps"
@@ -524,7 +524,7 @@ func (app *BaseApp) SetCircuitBreaker(cb CircuitBreaker) {
// GetConsensusParams returns the current consensus parameters from the BaseApp's
// ParamStore. If the BaseApp has no ParamStore defined, nil is returned.
func (app *BaseApp) GetConsensusParams(ctx sdk.Context) cmtproto.ConsensusParams {
func (app *BaseApp) GetConsensusParams(ctx context.Context) cmtproto.ConsensusParams {
if app.paramStore == nil {
return cmtproto.ConsensusParams{}
}
@@ -543,7 +543,7 @@ func (app *BaseApp) GetConsensusParams(ctx sdk.Context) cmtproto.ConsensusParams
// StoreConsensusParams sets the consensus parameters to the BaseApp's param
// store.
func (app *BaseApp) StoreConsensusParams(ctx sdk.Context, cp cmtproto.ConsensusParams) error {
func (app *BaseApp) StoreConsensusParams(ctx context.Context, cp cmtproto.ConsensusParams) error {
if app.paramStore == nil {
return errors.New("cannot store consensus params with no params store set")
}
@@ -581,7 +581,7 @@ func (app *BaseApp) GetMaximumBlockGas(ctx sdk.Context) uint64 {
}
}
func (app *BaseApp) validateFinalizeBlockHeight(req *abci.RequestFinalizeBlock) error {
func (app *BaseApp) validateFinalizeBlockHeight(req *abci.FinalizeBlockRequest) error {
if req.Height < 1 {
return fmt.Errorf("invalid height: %d", req.Height)
}
@@ -704,7 +704,7 @@ func (app *BaseApp) cacheTxContext(ctx sdk.Context, txBytes []byte) (sdk.Context
return ctx.WithMultiStore(msCache), msCache
}
func (app *BaseApp) preBlock(req *abci.RequestFinalizeBlock) error {
func (app *BaseApp) preBlock(req *abci.FinalizeBlockRequest) error {
if app.preBlocker != nil {
ctx := app.finalizeBlockState.Context()
if err := app.preBlocker(ctx, req); err != nil {
@@ -721,7 +721,7 @@ func (app *BaseApp) preBlock(req *abci.RequestFinalizeBlock) error {
return nil
}
func (app *BaseApp) beginBlock(req *abci.RequestFinalizeBlock) (sdk.BeginBlock, error) {
func (app *BaseApp) beginBlock(req *abci.FinalizeBlockRequest) (sdk.BeginBlock, error) {
var (
resp sdk.BeginBlock
err error
+30 -30
View File
@@ -10,7 +10,7 @@ import (
"time"
abci "github.com/cometbft/cometbft/abci/types"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
dbm "github.com/cosmos/cosmos-db"
"github.com/stretchr/testify/require"
@@ -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)
@@ -725,7 +725,7 @@ func TestABCI_CreateQueryContext(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
if tc.headerHeight != tc.height {
_, err := app.InitChain(&abci.RequestInitChain{
_, err := app.InitChain(&abci.InitChainRequest{
InitialHeight: tc.headerHeight,
})
require.NoError(t, err)
@@ -805,7 +805,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)
@@ -828,7 +828,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)
@@ -868,7 +868,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)
+3 -3
View File
@@ -53,7 +53,7 @@ func NewGRPCQueryRouter() *GRPCQueryRouter {
// GRPCQueryHandler defines a function type which handles ABCI Query requests
// using gRPC
type GRPCQueryHandler = func(ctx sdk.Context, req *abci.RequestQuery) (*abci.ResponseQuery, error)
type GRPCQueryHandler = func(ctx sdk.Context, req *abci.QueryRequest) (*abci.QueryResponse, error)
// Route returns the GRPCQueryHandler for a given query route path or nil
// if not found
@@ -106,7 +106,7 @@ func (qrt *GRPCQueryRouter) registerABCIQueryHandler(sd *grpc.ServiceDesc, metho
)
}
qrt.routes[fqName] = func(ctx sdk.Context, req *abci.RequestQuery) (*abci.ResponseQuery, error) {
qrt.routes[fqName] = func(ctx sdk.Context, req *abci.QueryRequest) (*abci.QueryResponse, error) {
// call the method handler from the service description with the handler object,
// a wrapped sdk.Context with proto-unmarshaled data from the ABCI request data
res, err := methodHandler(handler, ctx, func(i interface{}) error {
@@ -124,7 +124,7 @@ func (qrt *GRPCQueryRouter) registerABCIQueryHandler(sd *grpc.ServiceDesc, metho
}
// return the result bytes as the response value
return &abci.ResponseQuery{
return &abci.QueryResponse{
Height: req.Height,
Value: resBytes,
}, nil
+1 -1
View File
@@ -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
}
+2 -2
View File
@@ -151,7 +151,7 @@ func TestMsgService(t *testing.T) {
app.MsgServiceRouter(),
testdata.MsgServerImpl{},
)
_, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1})
_, err = app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1})
require.NoError(t, err)
_, _, addr := testdata.KeyTestPubAddr()
@@ -197,7 +197,7 @@ func TestMsgService(t *testing.T) {
// Send the tx to the app
txBytes, err := txConfig.TxEncoder()(txBuilder.GetTx())
require.NoError(t, err)
res, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1, Txs: [][]byte{txBytes}})
res, err := app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1, Txs: [][]byte{txBytes}})
require.NoError(t, err)
require.Equal(t, abci.CodeTypeOK, res.TxResults[0].Code, "res=%+v", res)
}
+6 -6
View File
@@ -15,7 +15,7 @@ import (
// FinalizeBlockFunc is the function that is called by the OE to finalize the
// block. It is the same as the one in the ABCI app.
type FinalizeBlockFunc func(context.Context, *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error)
type FinalizeBlockFunc func(context.Context, *abci.FinalizeBlockRequest) (*abci.FinalizeBlockResponse, error)
// OptimisticExecution is a struct that contains the OE context. It is used to
// run the FinalizeBlock function in a goroutine, and to abort it if needed.
@@ -25,8 +25,8 @@ type OptimisticExecution struct {
mtx sync.Mutex
stopCh chan struct{}
request *abci.RequestFinalizeBlock
response *abci.ResponseFinalizeBlock
request *abci.FinalizeBlockRequest
response *abci.FinalizeBlockResponse
err error
cancelFunc func() // cancel function for the context
initialized bool // A boolean value indicating whether the struct has been initialized
@@ -82,12 +82,12 @@ func (oe *OptimisticExecution) Initialized() bool {
}
// Execute initializes the OE and starts it in a goroutine.
func (oe *OptimisticExecution) Execute(req *abci.RequestProcessProposal) {
func (oe *OptimisticExecution) Execute(req *abci.ProcessProposalRequest) {
oe.mtx.Lock()
defer oe.mtx.Unlock()
oe.stopCh = make(chan struct{})
oe.request = &abci.RequestFinalizeBlock{
oe.request = &abci.FinalizeBlockRequest{
Txs: req.Txs,
DecidedLastCommit: req.ProposedLastCommit,
Misbehavior: req.Misbehavior,
@@ -154,7 +154,7 @@ func (oe *OptimisticExecution) Abort() {
}
// WaitResult waits for the OE to finish and returns the result.
func (oe *OptimisticExecution) WaitResult() (*abci.ResponseFinalizeBlock, error) {
func (oe *OptimisticExecution) WaitResult() (*abci.FinalizeBlockResponse, error) {
<-oe.stopCh
return oe.response, oe.err
}
+2 -2
View File
@@ -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())
+1 -1
View File
@@ -3,7 +3,7 @@ package baseapp
import (
"context"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
)
const InitialAppVersion uint64 = 0
+1 -1
View File
@@ -37,7 +37,7 @@ import (
"errors"
"fmt"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
sdk "github.com/cosmos/cosmos-sdk/types"
)
+29 -29
View File
@@ -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)
}
+8 -8
View File
@@ -6,7 +6,7 @@ import (
"testing"
abci "github.com/cometbft/cometbft/abci/types"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
tmproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
"github.com/stretchr/testify/require"
storetypes "cosmossdk.io/store/types"
@@ -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()
+1 -1
View File
@@ -1,7 +1,7 @@
package baseapp
import (
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
errorsmod "cosmossdk.io/errors"
+3 -3
View File
@@ -8,7 +8,7 @@ import (
context "context"
reflect "reflect"
crypto "github.com/cometbft/cometbft/proto/tendermint/crypto"
v1 "github.com/cometbft/cometbft/api/cometbft/crypto/v1"
types "github.com/cosmos/cosmos-sdk/types"
gomock "github.com/golang/mock/gomock"
)
@@ -37,10 +37,10 @@ func (m *MockValidatorStore) EXPECT() *MockValidatorStoreMockRecorder {
}
// GetPubKeyByConsAddr mocks base method.
func (m *MockValidatorStore) GetPubKeyByConsAddr(arg0 context.Context, arg1 types.ConsAddress) (crypto.PublicKey, error) {
func (m *MockValidatorStore) GetPubKeyByConsAddr(arg0 context.Context, arg1 types.ConsAddress) (v1.PublicKey, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetPubKeyByConsAddr", arg0, arg1)
ret0, _ := ret[0].(crypto.PublicKey)
ret0, _ := ret[0].(v1.PublicKey)
ret1, _ := ret[1].(error)
return ret0, ret1
}
+1 -1
View File
@@ -13,7 +13,7 @@ import (
"testing"
"unsafe"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
dbm "github.com/cosmos/cosmos-db"
"github.com/stretchr/testify/require"