Skip to content

Commit b93081d

Browse files
fix(baseapp): audit changes (#16596)
Co-authored-by: Aleksandr Bezobchuk <[email protected]>
1 parent 1afeca7 commit b93081d

File tree

8 files changed

+638
-76
lines changed

8 files changed

+638
-76
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
7575
* [#16547](https://github.com/cosmos/cosmos-sdk/pull/16547) Ensure a transaction's gas limit cannot exceed the block gas limit.
7676
* (x/auth/types) [#16554](https://github.com/cosmos/cosmos-sdk/pull/16554) `ModuleAccount.Validate` now reports a nil `.BaseAccount` instead of panicking.
7777
* (baseapp) [#16613](https://github.com/cosmos/cosmos-sdk/pull/16613) Ensure each message in a transaction has a registered handler, otherwise `CheckTx` will fail.
78+
* (baseapp) [#16596](https://github.com/cosmos/cosmos-sdk/pull/16596) Return error during ExtendVote and VerifyVoteExtension if the request height is earlier than `VoteExtensionsEnableHeight`.
7879
* (x/consensus) [#16713](https://github.com/cosmos/cosmos-sdk/pull/16713) Add missing ABCI param in MsgUpdateParams.
7980
* [#16639](https://github.com/cosmos/cosmos-sdk/pull/16639) Make sure we don't execute blocks beyond the halt height.
8081
* (baseapp) [#16700](https://github.com/cosmos/cosmos-sdk/pull/16700) Fix: Consensus Failure in returning no response to malformed transactions

UPGRADING.md

+15
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@ Additionally, the SDK is starting its abstraction from CometBFT Go types thoroug
2929
* The usage of CometBFT have been replaced to use the Cosmos SDK logger interface (`cosmossdk.io/log.Logger`).
3030
* The usage of `github.com/cometbft/cometbft/libs/bytes.HexByte` have been replaced by `[]byte`.
3131

32+
#### Enable Vote Extensions
33+
34+
:::tip This is an optional feature that is disabled by default.
35+
36+
Once all the code changes required to implement Vote Extensions are in place,
37+
they can be enabled by setting the consensus param `Abci.VoteExtensionsEnableHeight`
38+
to a value greater than zero.
39+
40+
In a new chain, this can be done in the `genesis.json` file.
41+
42+
For existing chains this can be done in two ways:
43+
44+
- During an upgrade the value is set in an upgrade handler.
45+
- A governance proposal that changes the consensus param **after a coordinated upgrade has taken place**.
46+
3247
### BaseApp
3348

3449
All ABCI methods now accept a pointer to the request and response types defined

baseapp/abci.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,9 @@ func (app *BaseApp) ExtendVote(_ context.Context, req *abci.RequestExtendVote) (
556556
// If vote extensions are not enabled, as a safety precaution, we return an
557557
// error.
558558
cp := app.GetConsensusParams(app.voteExtensionState.ctx)
559-
if cp.Abci != nil && cp.Abci.VoteExtensionsEnableHeight <= 0 {
559+
560+
extsEnabled := cp.Abci != nil && req.Height >= cp.Abci.VoteExtensionsEnableHeight && cp.Abci.VoteExtensionsEnableHeight != 0
561+
if !extsEnabled {
560562
return nil, fmt.Errorf("vote extensions are not enabled; unexpected call to ExtendVote at height %d", req.Height)
561563
}
562564

@@ -569,6 +571,7 @@ func (app *BaseApp) ExtendVote(_ context.Context, req *abci.RequestExtendVote) (
569571
WithHeaderInfo(coreheader.Info{
570572
ChainID: app.chainID,
571573
Height: req.Height,
574+
Hash: req.Hash,
572575
})
573576

574577
// add a deferred recover handler in case extendVote panics
@@ -607,7 +610,9 @@ func (app *BaseApp) VerifyVoteExtension(req *abci.RequestVerifyVoteExtension) (r
607610
// If vote extensions are not enabled, as a safety precaution, we return an
608611
// error.
609612
cp := app.GetConsensusParams(app.voteExtensionState.ctx)
610-
if cp.Abci != nil && cp.Abci.VoteExtensionsEnableHeight <= 0 {
613+
614+
extsEnabled := cp.Abci != nil && req.Height >= cp.Abci.VoteExtensionsEnableHeight && cp.Abci.VoteExtensionsEnableHeight != 0
615+
if !extsEnabled {
611616
return nil, fmt.Errorf("vote extensions are not enabled; unexpected call to VerifyVoteExtension at height %d", req.Height)
612617
}
613618

0 commit comments

Comments
 (0)