Skip to content

Commit

Permalink
Merge pull request #769 from cosmos/release/v0.13.0
Browse files Browse the repository at this point in the history
Release/v0.13.0
  • Loading branch information
ebuchman authored Apr 2, 2018
2 parents 6f9db78 + e7e98a0 commit 797aec2
Show file tree
Hide file tree
Showing 93 changed files with 6,253 additions and 570 deletions.
19 changes: 10 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
# OS
.DS_Store
*.swp
*.swo
.vscode

# Build
vendor
merkleeyes.db
build
docs/guide/*.sh
tools/bin/*
examples/build/*
examples/basecoin/glide.lock
docs/_build

# Data - ideally these don't exist
examples/basecoin/app/data
baseapp/data/*
docs/_build
.DS_Store
coverage.txt
profile.out
.vscode

# Testing
coverage.txt
profile.out
client/lcd/keys.db/

### Vagrant ###
.vagrant/
Expand Down
34 changes: 33 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
# Changelog

## 0.13.0 (April 2, 2018)

BREAKING CHANGES

* [basecoin] Remove cool/sketchy modules -> moved to new `democoin`
* [basecoin] NewBasecoinApp takes a `map[string]dbm.DB` as temporary measure
to allow mounting multiple stores with their own DB until they can share one
* [staking] Renamed to `simplestake`
* [builder] Functions don't take `passphrase` as argument
* [server] GenAppState returns generated seed and address
* [basecoind] `init` command outputs JSON of everything necessary for testnet
* [basecoind] `basecoin.db -> data/basecoin.db`
* [basecli] `data/keys.db -> keys/keys.db`

FEATURES

* [types] `Coin` supports direct arithmetic operations
* [basecoind] Add `show_validator` and `show_node_id` commands
* [staking] Initial merge of full staking module!
* [democoin] New example application to demo custom modules

IMPROVEMENTS

* [makefile] `make install`
* [testing] Use `/tmp` for directories so they don't get left in the repo

BUG FIXES

* [basecoin] Allow app to be restarted
* [makefile] Fix build on Windows
* [basecli] Get confirmation before overriding key with same name

## 0.12.0 (March 27 2018)

BREAKING CHANGES
Expand All @@ -26,7 +58,7 @@ FEATURES
* [types] StdFee, and StdTx takes the StdFee
* [specs] Progression of MVPs for IBC
* [x/ibc] Initial shell of IBC functionality (no proofs)
* [x/staking] Simple staking module with bonding/unbonding
* [x/simplestake] Simple staking module with bonding/unbonding

IMPROVEMENTS

Expand Down
2 changes: 1 addition & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 20 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
PACKAGES=$(shell go list ./... | grep -v '/vendor/')
BUILD_FLAGS = -ldflags "-X github.com/cosmos/cosmos-sdk/version.GitCommit=`git rev-parse --short HEAD`"
COMMIT_HASH := $(shell git rev-parse --short HEAD)
BUILD_FLAGS = -ldflags "-X github.com/cosmos/cosmos-sdk/version.GitCommit=${COMMIT_HASH}"

all: check_tools get_vendor_deps build test

Expand All @@ -17,9 +18,25 @@ gaia:
go build $(BUILD_FLAGS) -o build/gaiacli ./examples/gaia/gaiacli

build:
@rm -rf examples/basecoin/vendor/
@rm -rf $(shell pwd)/examples/basecoin/vendor/
@rm -rf $(shell pwd)/examples/democoin/vendor/
ifeq ($(OS),Windows_NT)
go build $(BUILD_FLAGS) -o build/basecoind.exe ./examples/basecoin/cmd/basecoind
go build $(BUILD_FLAGS) -o build/basecli.exe ./examples/basecoin/cmd/basecli
go build $(BUILD_FLAGS) -o build/democoind.exe ./examples/democoin/cmd/democoind
go build $(BUILD_FLAGS) -o build/democli.exe ./examples/democoin/cmd/democli
else
go build $(BUILD_FLAGS) -o build/basecoind ./examples/basecoin/cmd/basecoind
go build $(BUILD_FLAGS) -o build/basecli ./examples/basecoin/cmd/basecli
go build $(BUILD_FLAGS) -o build/democoind ./examples/democoin/cmd/democoind
go build $(BUILD_FLAGS) -o build/democli ./examples/democoin/cmd/democli
endif

install:
go install $(BUILD_FLAGS) ./examples/basecoin/cmd/basecoind
go install $(BUILD_FLAGS) ./examples/basecoin/cmd/basecli
go install $(BUILD_FLAGS) ./examples/democoin/cmd/democoind
go install $(BUILD_FLAGS) ./examples/democoin/cmd/democli

dist:
@bash publish/dist.sh
Expand Down Expand Up @@ -68,13 +85,12 @@ test: test_unit # test_cli

test_unit:
@rm -rf examples/basecoin/vendor/
@rm -rf examples/democoin/vendor/
@go test $(PACKAGES)

test_cover:
@rm -rf examples/basecoin/vendor/
@rm -rf client/lcd/keys.db ~/.tendermint_test
@bash tests/test_cover.sh
@rm -rf client/lcd/keys.db ~/.tendermint_test

benchmark:
@go test -bench=. $(PACKAGES)
Expand Down
16 changes: 16 additions & 0 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package baseapp

import (
"encoding/json"
"fmt"
"runtime/debug"

Expand Down Expand Up @@ -54,6 +55,7 @@ type BaseApp struct {
var _ abci.Application = (*BaseApp)(nil)

// Create and name new BaseApp
// NOTE: The db is used to store the version number for now.
func NewBaseApp(name string, logger log.Logger, db dbm.DB) *BaseApp {
return &BaseApp{
Logger: logger,
Expand All @@ -70,12 +72,18 @@ func (app *BaseApp) Name() string {
}

// Mount a store to the provided key in the BaseApp multistore
// Broken until #532 is implemented.
func (app *BaseApp) MountStoresIAVL(keys ...*sdk.KVStoreKey) {
for _, key := range keys {
app.MountStore(key, sdk.StoreTypeIAVL)
}
}

// Mount a store to the provided key in the BaseApp multistore
func (app *BaseApp) MountStoreWithDB(key sdk.StoreKey, typ sdk.StoreType, db dbm.DB) {
app.cms.MountStoreWithDB(key, typ, db)
}

// Mount a store to the provided key in the BaseApp multistore
func (app *BaseApp) MountStore(key sdk.StoreKey, typ sdk.StoreType) {
app.cms.MountStoreWithDB(key, typ, app.db)
Expand Down Expand Up @@ -233,6 +241,14 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC
app.setDeliverState(abci.Header{})
app.initChainer(app.deliverState.ctx, req) // no error

// Initialize module genesis state
genesisState := new(map[string]json.RawMessage)
err := json.Unmarshal(req.AppStateBytes, genesisState)
if err != nil {
// TODO Return something intelligent
panic(err)
}

// NOTE: we don't commit, but BeginBlock for block 1
// starts from this deliverState

Expand Down
25 changes: 14 additions & 11 deletions baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ func TestMountStores(t *testing.T) {

// make some cap keys
capKey1 := sdk.NewKVStoreKey("key1")
db1 := dbm.NewMemDB()
capKey2 := sdk.NewKVStoreKey("key2")
db2 := dbm.NewMemDB()

// no stores are mounted
assert.Panics(t, func() { app.LoadLatestVersion(capKey1) })

app.MountStoresIAVL(capKey1, capKey2)
app.MountStoreWithDB(capKey1, sdk.StoreTypeIAVL, db1)
app.MountStoreWithDB(capKey2, sdk.StoreTypeIAVL, db2)

// stores are mounted
err := app.LoadLatestVersion(capKey1)
Expand Down Expand Up @@ -126,7 +129,6 @@ func TestTxDecoder(t *testing.T) {

// Test that Info returns the latest committed state.
func TestInfo(t *testing.T) {

app := newBaseApp(t.Name())

// ----- test an empty response -------
Expand All @@ -145,17 +147,19 @@ func TestInfo(t *testing.T) {
}

func TestInitChainer(t *testing.T) {
logger := defaultLogger()
db := dbm.NewMemDB()
name := t.Name()
db := dbm.NewMemDB()
logger := defaultLogger()
app := NewBaseApp(name, logger, db)

// make cap keys and mount the stores
// NOTE/TODO: mounting multiple stores is broken
// see https://github.com/cosmos/cosmos-sdk/issues/532
capKey := sdk.NewKVStoreKey("main")
// capKey2 := sdk.NewKVStoreKey("key2")
app.MountStoresIAVL(capKey) // , capKey2)
db1 := dbm.NewMemDB()
capKey2 := sdk.NewKVStoreKey("key2")
db2 := dbm.NewMemDB()
app.MountStoreWithDB(capKey, sdk.StoreTypeIAVL, db1)
app.MountStoreWithDB(capKey2, sdk.StoreTypeIAVL, db2)
err := app.LoadLatestVersion(capKey) // needed to make stores non-nil
assert.Nil(t, err)

Expand All @@ -180,16 +184,15 @@ func TestInitChainer(t *testing.T) {

// set initChainer and try again - should see the value
app.SetInitChainer(initChainer)
app.InitChain(abci.RequestInitChain{})
app.InitChain(abci.RequestInitChain{AppStateBytes: []byte("{}")}) // must have valid JSON genesis file, even if empty
app.Commit()
res = app.Query(query)
assert.Equal(t, value, res.Value)

// reload app
app = NewBaseApp(name, logger, db)
capKey = sdk.NewKVStoreKey("main")
// capKey2 = sdk.NewKVStoreKey("key2") // TODO
app.MountStoresIAVL(capKey) //, capKey2)
app.MountStoreWithDB(capKey, sdk.StoreTypeIAVL, db1)
app.MountStoreWithDB(capKey2, sdk.StoreTypeIAVL, db2)
err = app.LoadLatestVersion(capKey) // needed to make stores non-nil
assert.Nil(t, err)
app.SetInitChainer(initChainer)
Expand Down
2 changes: 1 addition & 1 deletion baseapp/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type Router interface {
Route(path string) (h sdk.Handler)
}

// map a transaction type to a handler
// map a transaction type to a handler and an initgenesis function
type route struct {
r string
h sdk.Handler
Expand Down
14 changes: 13 additions & 1 deletion client/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,23 @@ func SignAndBuild(name, passphrase string, msg sdk.Msg, cdc *wire.Codec) ([]byte
}

// sign and build the transaction from the msg
func SignBuildBroadcast(name string, passphrase string, msg sdk.Msg, cdc *wire.Codec) (*ctypes.ResultBroadcastTxCommit, error) {
func SignBuildBroadcast(name string, msg sdk.Msg, cdc *wire.Codec) (*ctypes.ResultBroadcastTxCommit, error) {
passphrase, err := GetPassphraseFromStdin(name)
if err != nil {
return nil, err
}

txBytes, err := SignAndBuild(name, passphrase, msg, cdc)
if err != nil {
return nil, err
}

return BroadcastTx(txBytes)
}

// get passphrase from std input
func GetPassphraseFromStdin(name string) (pass string, err error) {
buf := client.BufferStdin()
prompt := fmt.Sprintf("Password to sign with '%s':", name)
return client.GetPassword(prompt, buf)
}
22 changes: 22 additions & 0 deletions client/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,28 @@ func GetCheckPassword(prompt, prompt2 string, buf *bufio.Reader) (string, error)
return pass, nil
}

// GetConfirmation will request user give the confirmation from stdin.
// "y", "Y", "yes", "YES", and "Yes" all count as confirmations.
// If the input is not recognized, it will ask again.
func GetConfirmation(prompt string, buf *bufio.Reader) (bool, error) {
for {
if inputIsTty() {
fmt.Print(fmt.Sprintf("%s [y/n]:", prompt))
}
response, err := readLineFromBuf(buf)
if err != nil {
return false, err
}

response = strings.ToLower(strings.TrimSpace(response))
if response == "y" || response == "yes" {
return true, nil
} else if response == "n" || response == "no" {
return false, nil
}
}
}

// inputIsTty returns true iff we have an interactive prompt,
// where we can disable echo and request to repeat the password.
// If false, we can optimize for piped input from another command
Expand Down
10 changes: 10 additions & 0 deletions client/keys/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ func runAddCmd(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}

_, err := kb.Get(name)
if err == nil {
// account exists, ask for user confirmation
if response, err := client.GetConfirmation(
fmt.Sprintf("override the existing name %s", name), buf); err != nil || !response {
return err
}
}

pass, err = client.GetCheckPassword(
"Enter a passphrase for your key:",
"Repeat the passphrase:", buf)
Expand Down
3 changes: 2 additions & 1 deletion client/keys/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keys

import (
"fmt"
"path/filepath"

"github.com/spf13/viper"

Expand Down Expand Up @@ -32,7 +33,7 @@ type KeyOutput struct {
func GetKeyBase() (keys.Keybase, error) {
if keybase == nil {
rootDir := viper.GetString(cli.HomeFlag)
db, err := dbm.NewGoLevelDB(KeyDBName, rootDir)
db, err := dbm.NewGoLevelDB(KeyDBName, filepath.Join(rootDir, "keys"))
if err != nil {
return nil, err
}
Expand Down
1 change: 0 additions & 1 deletion client/lcd/.gitignore

This file was deleted.

Loading

0 comments on commit 797aec2

Please sign in to comment.