Skip to content

Commit

Permalink
Merge branch 'develop' into fedekunze/README
Browse files Browse the repository at this point in the history
  • Loading branch information
fedekunze committed Apr 9, 2018
2 parents c155a82 + 9b246ec commit 56c3ae4
Show file tree
Hide file tree
Showing 100 changed files with 3,517 additions and 2,132 deletions.
26 changes: 15 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
# Changelog

## 0.13.0 (TBD)
## 0.13.1 (April 3, 2018)

BUG FIXES

* [x/ibc] Fix CLI and relay for IBC txs
* [x/stake] Various fixes/improvements

## 0.13.0 (April 2, 2018)

BREAKING CHANGES

* [baseapp] `AddRoute` takes an `InitGenesis` function for per-module
initialization
* [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`
* [x/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`
* [cool] Mapper -> Keeper

FEATURES

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

IMPROVEMENTS
Expand All @@ -45,9 +49,9 @@ BREAKING CHANGES
* [types] Replace tx.GetFeePayer with FeePayer(tx) - returns the first signer
* [types] NewStdTx takes the Fee
* [types] ParseAccount -> AccountDecoder; ErrTxParse -> ErrTxDecoder
* [auth] AnteHandler deducts fees
* [bank] Move some errors to `types`
* [bank] Remove sequence and signature from Input
* [x/auth] AnteHandler deducts fees
* [x/bank] Move some errors to `types`
* [x/bank] Remove sequence and signature from Input

FEATURES

Expand All @@ -71,8 +75,8 @@ IMPROVEMENTS
* [specs] Staking

BUG FIXES
* [auth] Fix setting pubkey on new account
* [auth] Require signatures to include the sequences
* [x/auth] Fix setting pubkey on new account
* [x/auth] Require signatures to include the sequences
* [baseapp] Dont panic on nil handler
* [basecoin] Check for empty bytes in account and tx

Expand Down
34 changes: 17 additions & 17 deletions Gopkg.lock

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

6 changes: 3 additions & 3 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@
name = "github.com/tendermint/iavl"

[[constraint]]
version = "~0.17.1"
version = "~0.18.0-rc1"
name = "github.com/tendermint/tendermint"

[[constraint]]
version = "~0.7.1"
[[override]]
version = "~0.8.1"
name = "github.com/tendermint/tmlibs"

[prune]
Expand Down
26 changes: 15 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PACKAGES=$(shell go list ./... | grep -v '/vendor/')
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
all: check_tools get_vendor_deps build build_examples test

########################################
### CI
Expand All @@ -13,13 +13,16 @@ ci: get_tools get_vendor_deps build test_cover
### Build

# This can be unified later, here for easy demos
gaia:
go build $(BUILD_FLAGS) -o build/gaiad ./examples/gaia/gaiad
go build $(BUILD_FLAGS) -o build/gaiacli ./examples/gaia/gaiacli

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

build_examples:
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
Expand All @@ -33,6 +36,10 @@ else
endif

install:
go install $(BUILD_FLAGS) ./cmd/gaiad
go install $(BUILD_FLAGS) ./cmd/gaiacli

install_examples:
go install $(BUILD_FLAGS) ./examples/basecoin/cmd/basecoind
go install $(BUILD_FLAGS) ./examples/basecoin/cmd/basecli
go install $(BUILD_FLAGS) ./examples/democoin/cmd/democoind
Expand Down Expand Up @@ -84,12 +91,9 @@ test: test_unit # test_cli
# go test -coverprofile=c.out && go tool cover -html=c.out

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

test_cover:
@rm -rf examples/basecoin/vendor/
@bash tests/test_cover.sh

benchmark:
Expand Down Expand Up @@ -123,4 +127,4 @@ devdoc_update:
# To avoid unintended conflicts with file names, always add to .PHONY
# unless there is a reason not to.
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
.PHONY: build dist check_tools get_tools get_vendor_deps draw_deps test test_unit test_tutorial benchmark devdoc_init devdoc devdoc_save devdoc_update
.PHONY: build build_examples install install_examples dist check_tools get_tools get_vendor_deps draw_deps test test_unit test_tutorial benchmark devdoc_init devdoc devdoc_save devdoc_update
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ The key directories of the SDK are:

## Getting Started

See the [documentation](https://cosmos-sdk.readthedocs.io).
See the [documentation](https://cosmos-sdk.readthedocs.io).
7 changes: 1 addition & 6 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,6 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC
// TODO Return something intelligent
panic(err)
}
err = app.Router().InitGenesis(app.deliverState.ctx, *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 All @@ -266,7 +261,7 @@ func (app *BaseApp) Query(req abci.RequestQuery) (res abci.ResponseQuery) {
queryable, ok := app.cms.(sdk.Queryable)
if !ok {
msg := "application doesn't support queries"
return sdk.ErrUnknownRequest(msg).Result().ToQuery()
return sdk.ErrUnknownRequest(msg).QueryResult()
}
return queryable.Query(req)
}
Expand Down
6 changes: 3 additions & 3 deletions baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func TestDeliverTx(t *testing.T) {

counter += 1
return sdk.Result{}
}, nil)
})

tx := testUpdatePowerTx{} // doesn't matter
header := abci.Header{AppHash: []byte("apphash")}
Expand Down Expand Up @@ -284,7 +284,7 @@ func TestQuery(t *testing.T) {
store := ctx.KVStore(capKey)
store.Set(key, value)
return sdk.Result{}
}, nil)
})

query := abci.RequestQuery{
Path: "/main/key",
Expand Down Expand Up @@ -349,7 +349,7 @@ func TestValidatorChange(t *testing.T) {
app.Router().AddRoute(msgType, func(ctx sdk.Context, msg sdk.Msg) sdk.Result {
// TODO
return sdk.Result{}
}, nil)
})

// Load latest state, which should be empty.
err := app.LoadLatestVersion(capKey)
Expand Down
27 changes: 3 additions & 24 deletions baseapp/router.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
package baseapp

import (
"encoding/json"
"fmt"
"regexp"

sdk "github.com/cosmos/cosmos-sdk/types"
)

// Router provides handlers for each transaction type.
type Router interface {
AddRoute(r string, h sdk.Handler, i sdk.InitGenesis) (rtr Router)
AddRoute(r string, h sdk.Handler) (rtr Router)
Route(path string) (h sdk.Handler)
InitGenesis(ctx sdk.Context, data map[string]json.RawMessage) error
}

// map a transaction type to a handler and an initgenesis function
type route struct {
r string
h sdk.Handler
i sdk.InitGenesis
}

type router struct {
Expand All @@ -38,11 +34,11 @@ func NewRouter() *router {
var isAlpha = regexp.MustCompile(`^[a-zA-Z]+$`).MatchString

// AddRoute - TODO add description
func (rtr *router) AddRoute(r string, h sdk.Handler, i sdk.InitGenesis) Router {
func (rtr *router) AddRoute(r string, h sdk.Handler) Router {
if !isAlpha(r) {
panic("route expressions can only contain alphanumeric characters")
}
rtr.routes = append(rtr.routes, route{r, h, i})
rtr.routes = append(rtr.routes, route{r, h})

return rtr
}
Expand All @@ -57,20 +53,3 @@ func (rtr *router) Route(path string) (h sdk.Handler) {
}
return nil
}

// InitGenesis - call `InitGenesis`, where specified, for all routes
// Return the first error if any, otherwise nil
func (rtr *router) InitGenesis(ctx sdk.Context, data map[string]json.RawMessage) error {
for _, route := range rtr.routes {
if route.i != nil {
encoded, found := data[route.r]
if !found {
return sdk.ErrGenesisParse(fmt.Sprintf("Expected module genesis information for module %s but it was not present", route.r))
}
if err := route.i(ctx, encoded); err != nil {
return err
}
}
}
return nil
}
27 changes: 27 additions & 0 deletions client/context/viper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package context

import (
"github.com/spf13/viper"

rpcclient "github.com/tendermint/tendermint/rpc/client"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/core"
)

func NewCoreContextFromViper() core.CoreContext {
nodeURI := viper.GetString(client.FlagNode)
var rpc rpcclient.Client
if nodeURI != "" {
rpc = rpcclient.NewHTTP(nodeURI, "/websocket")
}
return core.CoreContext{
ChainID: viper.GetString(client.FlagChainID),
Height: viper.GetInt64(client.FlagHeight),
TrustNode: viper.GetBool(client.FlagTrustNode),
FromAddressName: viper.GetString(client.FlagName),
NodeURI: nodeURI,
Sequence: viper.GetInt64(client.FlagSequence),
Client: rpc,
}
}
Loading

0 comments on commit 56c3ae4

Please sign in to comment.