Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return bnsd version on abci_info #1194

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
2 changes: 1 addition & 1 deletion app/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
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
davepuchyr marked this conversation as resolved.
Show resolved Hide resolved
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