diff --git a/.travis.yml b/.travis.yml index 60a35c1b..6e95f78f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,6 +35,8 @@ env: - GO111MODULE=on - TM_VERSION=v0.31.11 - BUILD_VERSION=$(echo ${TRAVIS_COMMIT} | cut -c 1-10) + - INT_TAG=$(echo ${TRAVIS_TAG} | tr -dc '0-9') + - APP_VERSION=${INT_TAG:=0} - MAIN_GO_VERSION=1.12.14 - GORACE="halt_on_error=1" - FORCE_TM_TEST=1 diff --git a/CHANGELOG.md b/CHANGELOG.md index c811c2c3..9c557916 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/app/store.go b/app/store.go index 86db6ed8..b718c4a4 100644 --- a/app/store.go +++ b/app/store.go @@ -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, @@ -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, } diff --git a/app/store_test.go b/app/store_test.go index 04b8fc1a..3522164a 100644 --- a/app/store_test.go +++ b/app/store_test.go @@ -19,7 +19,7 @@ func TestAddValChange(t *testing.T) { Type: "test", Data: []byte("someKey2"), } - app := NewStoreApp("dummy", iavl.MockCommitStore(), weave.NewQueryRouter(), context.Background()) + app := NewStoreApp("dummy", 1, iavl.MockCommitStore(), weave.NewQueryRouter(), context.Background()) t.Run("Diff is equal to output with one update", func(t *testing.T) { diff := []weave.ValidatorUpdate{ diff --git a/cmd/bnsd/Makefile b/cmd/bnsd/Makefile index 895a3cc1..ce638fb7 100644 --- a/cmd/bnsd/Makefile +++ b/cmd/bnsd/Makefile @@ -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}" diff --git a/cmd/bnsd/app/app.go b/cmd/bnsd/app/app.go index 229ca09a..5cfc4ea2 100644 --- a/cmd/bnsd/app/app.go +++ b/cmd/bnsd/app/app.go @@ -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, @@ -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 diff --git a/cmd/bnsd/app/init.go b/cmd/bnsd/app/init.go index 7d1c9bca..1cf90c59 100644 --- a/cmd/bnsd/app/init.go +++ b/cmd/bnsd/app/init.go @@ -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 } @@ -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) } diff --git a/cmd/bnsd/app/version.go b/cmd/bnsd/app/version.go new file mode 100644 index 00000000..1737ab38 --- /dev/null +++ b/cmd/bnsd/app/version.go @@ -0,0 +1,15 @@ +package bnsd + +import "strconv" + +// AppVersion should be set by release tag without v prefix and dots, example: v1.0.1 -> 101 +var AppVersion = "0" + +// tendermint expects app version as uint64 +func getAppVersion() uint64 { + appVersion, err := strconv.ParseUint(AppVersion, 10, 64) + if err != nil { + panic(err) + } + return appVersion +} diff --git a/cmd/bnsd/main.go b/cmd/bnsd/main.go index cc38accd..38901ffd 100644 --- a/cmd/bnsd/main.go +++ b/cmd/bnsd/main.go @@ -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" @@ -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) }