config: use a different source of versioning (#9486)

This commit is contained in:
Callum Waters
2022-10-04 15:01:32 +02:00
committed by GitHub
parent 5c23ffb05b
commit a02cc30e41
6 changed files with 22 additions and 21 deletions

View File

@@ -4,14 +4,8 @@ OUTPUT?=$(BUILDDIR)/tendermint
BUILD_TAGS?=tendermint
# If building a release, please checkout the version tag to get the correct version setting
ifneq ($(shell git symbolic-ref -q --short HEAD),)
VERSION := unreleased-$(shell git symbolic-ref -q --short HEAD)-$(shell git rev-parse HEAD)
else
VERSION := $(shell git describe)
endif
LD_FLAGS = -X github.com/tendermint/tendermint/version.TMCoreSemVer=$(VERSION)
COMMIT_HASH := $(shell git rev-parse --short HEAD)
LD_FLAGS = -X github.com/tendermint/tendermint/version.TMGitCommitHash=$(COMMIT_HASH)
BUILD_FLAGS = -mod=readonly -ldflags "$(LD_FLAGS)"
HTTPS_GIT := https://github.com/tendermint/tendermint.git
CGO_ENABLED ?= 0

View File

@@ -79,7 +79,7 @@ func NewApplication() *Application {
func (app *Application) Info(req types.RequestInfo) (resInfo types.ResponseInfo) {
return types.ResponseInfo{
Data: fmt.Sprintf("{\"size\":%v}", app.state.Size),
Version: version.ABCIVersion,
Version: version.ABCISemVer,
AppVersion: ProtocolVersion,
LastBlockHeight: app.state.Height,
LastBlockAppHash: app.state.AppHash,

View File

@@ -6,4 +6,4 @@ import (
// TODO: eliminate this after some version refactor
const Version = version.ABCIVersion
const Version = version.ABCISemVer

View File

@@ -14,6 +14,11 @@ var VersionCmd = &cobra.Command{
Use: "version",
Short: "Show version info",
Run: func(cmd *cobra.Command, args []string) {
tmVersion := version.TMCoreSemVer
if version.TMGitCommitHash != "" {
tmVersion += "+" + version.TMGitCommitHash
}
if verbose {
values, _ := json.MarshalIndent(struct {
Tendermint string `json:"tendermint"`
@@ -21,14 +26,14 @@ var VersionCmd = &cobra.Command{
BlockProtocol uint64 `json:"block_protocol"`
P2PProtocol uint64 `json:"p2p_protocol"`
}{
Tendermint: version.TMCoreSemVer,
ABCI: version.ABCIVersion,
Tendermint: tmVersion,
ABCI: version.ABCISemVer,
BlockProtocol: version.BlockProtocol,
P2PProtocol: version.P2PProtocol,
}, "", " ")
fmt.Println(string(values))
} else {
fmt.Println(version.TMCoreSemVer)
fmt.Println(tmVersion)
}
},
}

View File

@@ -335,8 +335,10 @@ func logNodeStartupInfo(state sm.State, pubKey crypto.PubKey, logger, consensusL
// Log the version info.
logger.Info("Version info",
"tendermint_version", version.TMCoreSemVer,
"abci", version.ABCISemVer,
"block", version.BlockProtocol,
"p2p", version.P2PProtocol,
"commit_hash", version.TMGitCommitHash,
)
// If the state and software differ in block version, at least log it.

View File

@@ -1,18 +1,12 @@
package version
var TMCoreSemVer = TMVersionDefault
const (
// TMVersionDefault is the used as the fallback version of Tendermint Core
// when not using git describe. It is formatted with semantic versioning.
TMVersionDefault = "0.38.0-dev"
TMCoreSemVer = "0.38.0-dev"
// ABCISemVer is the semantic version of the ABCI protocol
ABCISemVer = "1.0.0"
ABCISemVer = "1.0.0"
ABCIVersion = ABCISemVer
)
var (
// P2PProtocol versions all p2p behavior and msgs.
// This includes proposer selection.
P2PProtocol uint64 = 8
@@ -21,3 +15,9 @@ var (
// This includes validity of blocks and state updates.
BlockProtocol uint64 = 11
)
var (
// TMGitCommitHash uses git rev-parse HEAD to find commit hash which is helpful
// for the engineering team when working with the tendermint binary. See Makefile
TMGitCommitHash = ""
)