Skip to content

Commit

Permalink
Return bnsd version on abci_info
Browse files Browse the repository at this point in the history
  • Loading branch information
orkunkl committed Apr 1, 2020
1 parent 5f7a63c commit b2d93b5
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 8 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ env:
- GO111MODULE=on
- TM_VERSION=v0.31.11
- BUILD_VERSION=$(echo ${TRAVIS_COMMIT} | cut -c 1-10)
- APP_VERSION=$(echo ${TRAVIS_TAG} | tr -dc '0-9')
- MAIN_GO_VERSION=1.12.14
- GORACE="halt_on_error=1"
- FORCE_TM_TEST=1
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## HEAD
- `bnsd`: return app version on abci_info
- `bnsd`: revert burn feature
- `bnsd`: when a domain is transferred accounts ownership is transferred to the new domain owner and accounts' targets are cleared
- `bnsapi`: move bnsapi to new repo
Expand Down
9 changes: 7 additions & 2 deletions app/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,20 @@ type StoreApp struct {
// blockContext contains context info that is valid for the
// current block (eg. height, header), reset on BeginBlock
blockContext weave.Context

// current version of bnsd
appVersion uint64
}

// NewStoreApp initializes this app into a ready state with some defaults
//
// panics if unable to properly load the state from the given store
// TODO: is this correct? nothing else to do really....
func NewStoreApp(name string, store weave.CommitKVStore,
func NewStoreApp(name string, appVersion uint64, store weave.CommitKVStore,
queryRouter weave.QueryRouter, baseContext weave.Context) *StoreApp {
s := &StoreApp{
name: name,
name: name,
appVersion: appVersion,
// note: panics if trouble initializing from store
store: NewCommitStore(store),
queryRouter: queryRouter,
Expand Down Expand Up @@ -183,6 +187,7 @@ func (s *StoreApp) Info(req abci.RequestInfo) abci.ResponseInfo {

return abci.ResponseInfo{
Data: s.name,
AppVersion: s.appVersion,
LastBlockHeight: info.Version,
LastBlockAppHash: info.Hash,
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/bnsd/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.PHONY: all build test image tf protoc clean dist

BUILD_VERSION ?= manual
BUILD_FLAGS := -mod=readonly -ldflags "-X github.com/iov-one/weave.Version=${BUILD_VERSION}"
APP_VERSION ?= 1
BUILD_FLAGS := -mod=readonly -ldflags "-X github.com/iov-one/weave.Version=${BUILD_VERSION} -X github.com/iov-one/weave/cmd/bnsd/app.AppVersion=${APP_VERSION}"
DOCKER_BUILD_FLAGS := -a -installsuffix cgo
BUILDOUT ?= bnsd
IMAGE_NAME = "iov1/bnsd:${BUILD_VERSION}"
Expand Down
3 changes: 2 additions & 1 deletion cmd/bnsd/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ func CronStack() weave.Handler {
// for the Handler, just use Stack().
func Application(
name string,
appVersion uint64,
h weave.Handler,
tx weave.TxDecoder,
dbPath string,
Expand All @@ -185,7 +186,7 @@ func Application(
if err != nil {
return app.BaseApp{}, errors.Wrap(err, "cannot create store")
}
store := app.NewStoreApp(name, kv, QueryRouter(options.MinFee), ctx)
store := app.NewStoreApp(name, appVersion, kv, QueryRouter(options.MinFee), ctx)
ticker := cron.NewTicker(CronStack(), CronTaskMarshaler)
base := app.NewBaseApp(store, tx, h, ticker, options.Debug)
return base, nil
Expand Down
4 changes: 2 additions & 2 deletions cmd/bnsd/app/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func GenerateApp(options *server.Options) (abci.Application, error) {
}

stack := Stack(nil, options.MinFee)
application, err := Application("bnsd", stack, TxDecoder, dbPath, options)
application, err := Application("bnsd", getAppVersion(), stack, TxDecoder, dbPath, options)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -119,7 +119,7 @@ func InlineApp(kv weave.CommitKVStore, logger log.Logger, debug bool) abci.Appli
minFee := coin.Coin{}
stack := Stack(nil, minFee)
ctx := context.Background()
store := app.NewStoreApp("bnsd", kv, QueryRouter(minFee), ctx)
store := app.NewStoreApp("bnsd", getAppVersion(), kv, QueryRouter(minFee), ctx)
base := app.NewBaseApp(store, TxDecoder, stack, nil, debug)
return DecorateApp(base, logger)
}
Expand Down
16 changes: 16 additions & 0 deletions cmd/bnsd/app/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package bnsd

import "strconv"

// AppVersion should be set by build flags: `git describe --tags`
// It must be release tag without v prefix and dots
var AppVersion = "please set in makefile"

// tendermint expects app version as uint64
func getAppVersion() uint64 {
appVersion, err := strconv.ParseUint(AppVersion, 10, 64)
if err != nil {
panic(err)
}
return appVersion
}
3 changes: 1 addition & 2 deletions cmd/bnsd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"os"
"path/filepath"

"github.com/iov-one/weave"
bnsd "github.com/iov-one/weave/cmd/bnsd/app"
"github.com/iov-one/weave/commands"
"github.com/iov-one/weave/commands/server"
Expand Down Expand Up @@ -70,7 +69,7 @@ func main() {
case "testgen":
err = commands.TestGenCmd(bnsd.Examples(), rest)
case "version":
fmt.Println(weave.Version)
fmt.Println(bnsd.AppVersion)
default:
err = fmt.Errorf("unknown command: %s", cmd)
}
Expand Down

0 comments on commit b2d93b5

Please sign in to comment.