diff --git a/mod/consensus/pkg/cometbft/service/abci.go b/mod/consensus/pkg/cometbft/service/abci.go index 6a4171c03d..f715c3636e 100644 --- a/mod/consensus/pkg/cometbft/service/abci.go +++ b/mod/consensus/pkg/cometbft/service/abci.go @@ -39,6 +39,7 @@ import ( cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + sdkversion "github.com/cosmos/cosmos-sdk/version" "github.com/sourcegraph/conc/iter" ) @@ -177,21 +178,18 @@ func (s *Service[LoggerT]) Info( *cmtabci.InfoRequest, ) (*cmtabci.InfoResponse, error) { lastCommitID := s.sm.CommitMultiStore().LastCommitID() - appVersion := InitialAppVersion + appVersion := initialAppVersion if lastCommitID.Version > 0 { - ctx, err := s.CreateQueryContext(lastCommitID.Version, false) - if err != nil { - return nil, fmt.Errorf("failed creating query context: %w", err) - } - appVersion, err = s.AppVersion(ctx) + var err error + appVersion, err = s.appVersion() if err != nil { return nil, fmt.Errorf("failed getting app version: %w", err) } } return &cmtabci.InfoResponse{ - Data: s.name, - Version: s.version, + Data: appName, + Version: sdkversion.Version, AppVersion: appVersion, LastBlockHeight: lastCommitID.Version, LastBlockAppHash: lastCommitID.Hash, @@ -522,7 +520,7 @@ func (s *Service[LoggerT]) CreateQueryContext( return sdk.Context{}, errorsmod.Wrapf( sdkerrors.ErrInvalidHeight, "%s is not ready; please wait for first block", - s.name, + appName, ) } diff --git a/mod/consensus/pkg/cometbft/service/service.go b/mod/consensus/pkg/cometbft/service/service.go index 4e55666106..58b1e6be00 100644 --- a/mod/consensus/pkg/cometbft/service/service.go +++ b/mod/consensus/pkg/cometbft/service/service.go @@ -40,10 +40,12 @@ import ( "github.com/cometbft/cometbft/proxy" dbm "github.com/cosmos/cosmos-db" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/version" ) -const InitialAppVersion uint64 = 0 +const ( + initialAppVersion uint64 = 0 + appName string = "beacond" +) type Service[ LoggerT log.AdvancedLogger[LoggerT], @@ -52,7 +54,6 @@ type Service[ cmtCfg *cmtcfg.Config logger LoggerT - name string sm *statem.Manager Middleware MiddlewareI @@ -67,8 +68,6 @@ type Service[ initialHeight int64 minRetainBlocks uint64 - // application's version string - version string chainID string } @@ -85,7 +84,6 @@ func NewService[ ) *Service[LoggerT] { s := &Service[LoggerT]{ logger: logger, - name: "beacond", sm: statem.NewManager( db, servercmtlog.WrapSDKLogger(logger), @@ -93,7 +91,6 @@ func NewService[ Middleware: middleware, cmtCfg: cmtCfg, paramStore: params.NewConsensusParamsStore(cs), - version: version.Version, } s.MountStore(storeKey, storetypes.StoreTypeIAVL) @@ -166,7 +163,7 @@ func (s *Service[_]) Close() error { // Name returns the name of the cometbft. func (s *Service[_]) Name() string { - return s.name + return appName } // CommitMultiStore returns the CommitMultiStore of the cometbft. @@ -176,6 +173,10 @@ func (s *Service[_]) CommitMultiStore() storetypes.CommitMultiStore { // AppVersion returns the application's protocol version. func (s *Service[_]) AppVersion(_ context.Context) (uint64, error) { + return s.appVersion() +} + +func (s *Service[_]) appVersion() (uint64, error) { cp := s.paramStore.Get() return cp.Version.App, nil }