-
Notifications
You must be signed in to change notification settings - Fork 11
refactor!: upgrade to CometBFT v1.0.1 with Mempool lanes and DOG support + CheckTxHandler #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor!: upgrade to CometBFT v1.0.1 with Mempool lanes and DOG support + CheckTxHandler #42
Conversation
* 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
* Remove go toolchain from go.mod files
… descriptor registry
* Generate pulsar files * Fix ABCI unit test in baseapp * Fix genesis tests * Remove Go toolchains * Fix remaining breaking changes of Comet v1 ABCI types
…tore fork bumped to CometBFT v1
Co-authored-by: Julien Robert <[email protected]>
Co-authored-by: Aaron Craelius <[email protected]>
…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
| "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 |
There was a problem hiding this comment.
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
| break | ||
| } | ||
| } | ||
| intStringLen := int(stringLen) |
Check failure
Code scanning / gosec
integer overflow conversion uint64 -> uint8 Error
| } | ||
|
|
||
| return &abci.CheckTxResponse{ | ||
| GasWanted: int64(gInfo.GasWanted), // TODO: Should type accept unsigned ints? |
Check failure
Code scanning / gosec
integer overflow conversion uint64 -> uint8 Error
|
|
||
| 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
This PR bumps
CometBFTtov1.0.1and adds theCheckTxHandlerto support the Mempool lanes feature (backport #21979).Note that the final
CometBFTversion this SDK fork imports will be updated once this PR against CometBFT is merged.Notable Changes
sr25519curve support has been removed, asCometBFT v1deprecated it, (see PR #3646).PebbleDBhas some issues inCometBFT v1, soGoLevelDBshould be used instead.Testing Status
The Cosmos SDK fork
v0.50.9-inj-4has failing tests, mostly due to changes in thex/bankmodule (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-dbtov1.1.1fixed thePebbleDBissue.