Skip to content

Conversation

@sainoe
Copy link
Collaborator

@sainoe sainoe commented Mar 12, 2025

This PR bumps CometBFT to v1.0.1 and adds the CheckTxHandler to support the Mempool lanes feature (backport #21979).

Note that the final CometBFT version this SDK fork imports will be updated once this PR against CometBFT is merged.

Notable Changes

  • sr25519 curve support has been removed, as CometBFT v1 deprecated it, (see PR #3646).
  • PebbleDB has some issues in CometBFT v1, so GoLevelDB should be used instead.

Testing Status

The Cosmos SDK fork v0.50.9-inj-4 has failing tests, mostly due to changes in the x/bank module (f173a77dd). This PR fixes all unit and E2E tests, but some integration tests remain broken due to these changes. Fixing them would require a large refactor of the integration test setup, which is out of scope and would introduce even more changes than this PR already does.

Another observation is that the changes to the SDK store introduced by this commit aren't currently covered by any tests.

Edit: Bumping cosmos-db to v1.1.1 fixed the PebbleDB issue.

sainoe and others added 30 commits March 3, 2025 15:20
* Add CometBFT v1 buf registry commit to buf.yaml
* Update tendermint to comet import in proto files
* Replace tendermint to comet imports in Go files
* Remove deprecated sr25519 support starting from CometBFT v1.0.1
* Update SDK go.mod to use local ./api, which is upgraded to Comet v1, instead of cosmossdk.io/api v0.7.5
* Generate proto and pulsar files and remove tendermint from ./proto
* Generate pulsar files
* Fix ABCI unit test in baseapp
* Fix genesis tests
* Remove Go toolchains
* Fix remaining breaking changes of Comet v1 ABCI types
…mos#20266)

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…itSync bool and is never tested

* Fix building errors in integration tests introduced by f173a77 which breaks all integration tests using the bank keeper
* Remove deprecated MsgEditValidator ValidateBasic function which was breaking some related CLI test in x/staking
* Update base block gas in block gas tests
Comment on lines 317 to 383
"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
}
}

// CheckTx implements the ABCI interface and executes a tx in CheckTx mode. In
// CheckTx mode, messages are not executed. This means messages are only validated
// and only the AnteHandler is executed. State is persisted to the BaseApp's
// internal CheckTx state if the AnteHandler passes. Otherwise, the ResponseCheckTx
// internal CheckTx state if the AnteHandler passes. Otherwise, the CheckTxResponse
// 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) {
// the CheckTxResponse will contain relevant gas execution context.
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:
return nil, fmt.Errorf("unknown RequestCheckTx type: %s", req.Type)
return nil, fmt.Errorf("unknown CheckTxRequest type: %s", req.Type)
}

gInfo, result, anteEvents, err := app.runTx(mode, req.Tx)
if err != nil {
return sdkerrors.ResponseCheckTxWithEvents(err, gInfo.GasWanted, gInfo.GasUsed, anteEvents, app.trace), nil
if app.checkTxHandler == nil {
gInfo, result, anteEvents, err := app.runTx(mode, req.Tx, nil)
if err != nil {
return sdkerrors.CheckTxResponseWithEvents(err, gInfo.GasWanted, gInfo.GasUsed, anteEvents, app.trace), nil
}

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,
Data: result.Data,
Events: sdk.MarkEventsToIndex(result.Events, app.indexEvents),
}, nil
}

return &abci.ResponseCheckTx{
GasWanted: int64(gInfo.GasWanted), // TODO: Should type accept unsigned ints?
GasUsed: int64(gInfo.GasUsed), // TODO: Should type accept unsigned ints?
Log: result.Log,
Data: result.Data,
Events: sdk.MarkEventsToIndex(result.Events, app.indexEvents),
}, nil
// Create wrapper to avoid users overriding the execution mode
runTx := func(txBytes []byte, tx sdk.Tx) (gInfo sdk.GasInfo, result *sdk.Result, anteEvents []abci.Event, err error) {
return app.runTx(mode, txBytes, tx)
}

return app.checkTxHandler(runTx, req)
}

// PrepareProposal implements the PrepareProposal ABCI method and returns a
// ResponsePrepareProposal object to the client. The PrepareProposal method is
// PrepareProposalResponse object to the client. The PrepareProposal method is
// responsible for allowing the block proposer to perform application-dependent
// work in a block before proposing it.
//
// Transactions can be modified, removed, or added by the application. Since the
// application maintains its own local mempool, it will ignore the transactions
// provided to it in RequestPrepareProposal. Instead, it will determine which
// provided to it in PrepareProposalRequest. Instead, it will determine which
// transactions to return based on the mempool's semantics and the MaxTxBytes

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change potentially affects state.

Call sequence:

(*github.com/cosmos/cosmos-sdk/baseapp.BaseApp).PrepareProposal (baseapp/abci.go:379)

break
}
}
intStringLen := int(stringLen)

Check failure

Code scanning / gosec

integer overflow conversion uint64 -> uint8 Error

integer overflow conversion uint64 -> int
break
}
}
intStringLen := int(stringLen)

Check failure

Code scanning / gosec

integer overflow conversion uint64 -> uint8 Error

integer overflow conversion uint64 -> int
}

return &abci.CheckTxResponse{
GasWanted: int64(gInfo.GasWanted), // TODO: Should type accept unsigned ints?

Check failure

Code scanning / gosec

integer overflow conversion uint64 -> uint8 Error

integer overflow conversion uint64 -> int64

return &abci.CheckTxResponse{
GasWanted: int64(gInfo.GasWanted), // TODO: Should type accept unsigned ints?
GasUsed: int64(gInfo.GasUsed), // TODO: Should type accept unsigned ints?

Check failure

Code scanning / gosec

integer overflow conversion uint64 -> uint8 Error

integer overflow conversion uint64 -> int64
@sainoe sainoe marked this pull request as ready for review March 12, 2025 12:06
@nmarcetic nmarcetic requested a review from maxim-inj March 14, 2025 10:04
@maxim-inj maxim-inj merged commit a645082 into v0.50.9-inj-x-comet-v1 Mar 17, 2025
38 of 51 checks passed
@maxim-inj maxim-inj deleted the sainoe/v0.50.9-inj-x-comet-v1 branch March 17, 2025 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants