Skip to content

Commit

Permalink
Merge branch 'main' into cometBFT-some-more-cleanup-2
Browse files Browse the repository at this point in the history
  • Loading branch information
abi87 committed Sep 30, 2024
2 parents cfec782 + 320256c commit 7621133
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
16 changes: 7 additions & 9 deletions mod/consensus/pkg/cometbft/service/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
)
}

Expand Down
17 changes: 9 additions & 8 deletions mod/consensus/pkg/cometbft/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -52,7 +54,6 @@ type Service[
cmtCfg *cmtcfg.Config

logger LoggerT
name string
sm *statem.Manager
Middleware MiddlewareI

Expand All @@ -67,8 +68,6 @@ type Service[
initialHeight int64
minRetainBlocks uint64

// application's version string
version string
chainID string
}

Expand All @@ -85,15 +84,13 @@ func NewService[
) *Service[LoggerT] {
s := &Service[LoggerT]{
logger: logger,
name: "beacond",
sm: statem.NewManager(
db,
servercmtlog.WrapSDKLogger(logger),
),
Middleware: middleware,
cmtCfg: cmtCfg,
paramStore: params.NewConsensusParamsStore(cs),
version: version.Version,
}

s.MountStore(storeKey, storetypes.StoreTypeIAVL)
Expand Down Expand Up @@ -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.
Expand All @@ -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
}
Expand Down

0 comments on commit 7621133

Please sign in to comment.