Skip to content

Commit

Permalink
config: use a different source of versioning (#9486)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmwaters authored Oct 4, 2022
1 parent 5c23ffb commit a02cc30
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 21 deletions.
10 changes: 2 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion abci/example/kvstore/kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion abci/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import (

// TODO: eliminate this after some version refactor

const Version = version.ABCIVersion
const Version = version.ABCISemVer
11 changes: 8 additions & 3 deletions cmd/tendermint/commands/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,26 @@ 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"`
ABCI string `json:"abci"`
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)
}
},
}
Expand Down
2 changes: 2 additions & 0 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 8 additions & 8 deletions version/version.go
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 = ""
)

0 comments on commit a02cc30

Please sign in to comment.