refactor(baseapp): audit QA v0.52 (backport #21515) (#21520)

Co-authored-by: Julián Toledano <JulianToledano@users.noreply.github.com>
This commit is contained in:
mergify[bot] 2024-09-03 14:31:39 +00:00 committed by GitHub
parent fbfb6e59c9
commit a2e1cd0193
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 13 additions and 11 deletions

View File

@ -38,6 +38,8 @@ const (
QueryPathBroadcastTx = "/cosmos.tx.v1beta1.Service/BroadcastTx"
)
// InitChain implements the ABCI interface. It initializes the application's state
// and sets up the initial validator set.
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)
@ -135,6 +137,7 @@ func (app *BaseApp) InitChain(req *abci.InitChainRequest) (*abci.InitChainRespon
}, nil
}
// Info implements the ABCI interface. It returns information about the application.
func (app *BaseApp) Info(_ *abci.InfoRequest) (*abci.InfoResponse, error) {
lastCommitID := app.cms.LastCommitID()
appVersion := InitialAppVersion

View File

@ -23,7 +23,7 @@ import (
)
type (
// ValidatorStore defines the interface contract require for verifying vote
// ValidatorStore defines the interface contract required for verifying vote
// extension signatures. Typically, this will be implemented by the x/staking
// module, which has knowledge of the CometBFT public key.
ValidatorStore interface {
@ -84,7 +84,7 @@ func ValidateVoteExtensions(
totalVP += vote.Validator.Power
// Only check + include power if the vote is a commit vote. There must be super-majority, otherwise the
// previous block (the block vote is for) could not have been committed.
// previous block (the block the vote is for) could not have been committed.
if vote.BlockIdFlag != cmtproto.BlockIDFlagCommit {
continue
}

View File

@ -419,7 +419,7 @@ func (s *ABCIUtilsTestSuite) TestValidateVoteExtensionsIncorrectVotingPower() {
s.Require().Error(baseapp.ValidateVoteExtensions(s.ctx, s.valStore, llc))
}
func (s *ABCIUtilsTestSuite) TestValidateVoteExtensionsIncorrecOrder() {
func (s *ABCIUtilsTestSuite) TestValidateVoteExtensionsIncorrectOrder() {
ext := []byte("vote-extension")
cve := cmtproto.CanonicalVoteExtension{
Extension: ext,

View File

@ -6,9 +6,9 @@ import (
"github.com/cometbft/cometbft/abci/types"
)
// ExecuteGenesis implements a genesis TxHandler used to execute a genTxs (from genutil).
func (ba *BaseApp) ExecuteGenesisTx(tx []byte) error {
res := ba.deliverTx(tx)
// ExecuteGenesisTx implements a genesis TxHandler used to execute a genTxs (from genutil).
func (app *BaseApp) ExecuteGenesisTx(tx []byte) error {
res := app.deliverTx(tx)
if res.Code != types.CodeTypeOK {
return errors.New(res.Log)

View File

@ -43,9 +43,8 @@ func MakeHybridHandler(cdc codec.BinaryCodec, sd *grpc.ServiceDesc, method grpc.
}
if isProtov2Handler {
return makeProtoV2HybridHandler(methodDesc, cdc, method, handler)
} else {
return makeGogoHybridHandler(methodDesc, cdc, method, handler)
}
return makeGogoHybridHandler(methodDesc, cdc, method, handler)
}
// makeProtoV2HybridHandler returns a handler that can handle both gogo and protov2 messages.

View File

@ -47,7 +47,6 @@ func NewMsgServiceRouter() *MsgServiceRouter {
routes: map[string]MsgServiceHandler{},
hybridHandlers: map[string]func(ctx context.Context, req, resp protoiface.MessageV1) error{},
responseByMsgName: map[string]string{},
circuitBreaker: nil,
}
}

View File

@ -9,6 +9,7 @@ import (
abci "github.com/cometbft/cometbft/api/cometbft/abci/v1"
"github.com/spf13/cast"
"cosmossdk.io/log"
"cosmossdk.io/schema"
"cosmossdk.io/schema/appdata"
"cosmossdk.io/schema/decoding"
@ -36,7 +37,7 @@ func (app *BaseApp) EnableIndexer(indexerOpts interface{}, keys map[string]*stor
Config: indexerOpts,
Resolver: decoding.ModuleSetDecoderResolver(appModules),
SyncSource: nil,
Logger: app.logger.With("module", "indexer"),
Logger: app.logger.With(log.ModuleKey, "indexer"),
})
if err != nil {
return err

View File

@ -41,7 +41,7 @@ func (app *BaseApp) SimDeliver(txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.GasInfo,
}
// SimWriteState is an entrypoint for simulations only. They are not executed during the normal ABCI finalize
// block step but later. Therefore an extra call to the root multi-store (app.cms) is required to write the changes.
// block step but later. Therefore, an extra call to the root multi-store (app.cms) is required to write the changes.
func (app *BaseApp) SimWriteState() {
app.finalizeBlockState.ms.Write()
}