Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into alessio/safe-coins
Browse files Browse the repository at this point in the history
  • Loading branch information
rigelrozanski committed Feb 19, 2019
2 parents 0cc4b49 + 95710f1 commit 6e34853
Show file tree
Hide file tree
Showing 34 changed files with 493 additions and 1,408 deletions.
6 changes: 4 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,15 @@ jobs:
GAIAD_VERSION="stable"
elif [ "${CIRCLE_BRANCH}" == "develop" ]; then
GAIAD_VERSION="develop"
else
GAIAD_VERSION=`/tmp/workspace/bin/gaiad version`
fi
docker build -t tendermint/gaia:$GAIAD_VERSION .
docker login -u $DOCKER_USER -p $DOCKER_PASS
docker push tendermint/gaia:$GAIAD_VERSION
# Push the tag also for the version, so clients can build up on top of it
GAIAD_VERSION=`/tmp/workspace/bin/gaiad version`
docker push tendermint/gaia:$GAIAD_VERSION
workflows:
version: 2
test-suite:
Expand Down
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,43 @@
# Changelog

## 0.32.0

BREAKING CHANGES

* Gaia REST API
* [\#3642](https://github.com/cosmos/cosmos-sdk/pull/3642) `GET /tx/{hash}` now returns `404` instead of `500` if the transaction is not found

* SDK
* [\#3580](https://github.com/cosmos/cosmos-sdk/issues/3580) Migrate HTTP request/response types and utilities to types/rest.
* [\#3592](https://github.com/cosmos/cosmos-sdk/issues/3592) Drop deprecated keybase implementation's New() constructor in
favor of a new crypto/keys.New(string, string) implementation that
returns a lazy keybase instance. Remove client.MockKeyBase,
superseded by crypto/keys.NewInMemory()
* [\#3621](https://github.com/cosmos/cosmos-sdk/issues/3621) staking.GenesisState.Bonds -> Delegations

IMPROVEMENTS

* SDK
* [\#3311] Reconcile the `DecCoin/s` API with the `Coin/s` API.
* [\#3614] Add coin denom length checks to the coins constructors.
* [\#3621](https://github.com/cosmos/cosmos-sdk/issues/3621) remove many inter-module dependancies
* [\#3601] JSON-stringify the ABCI log response which includes the log and message
index.
* [\#3604] Improve SDK funds related error messages and allow for unicode in
JSON ABCI log.
* [\#3620](https://github.com/cosmos/cosmos-sdk/pull/3620) Version command shows build tags
* [\#3638] Add Bcrypt benchmarks & justification of security parameter choice
* [\#3648] Add JSON struct tags to vesting accounts.

* Tendermint
* [\#3618] Upgrade to Tendermint 0.30.03

BUG FIXES

* SDK
* [\#3646](https://github.com/cosmos/cosmos-sdk/issues/3646) `x/mint` now uses total token supply instead of total bonded tokens to calculate inflation


## 0.31.2

BREAKING CHANGES
Expand Down
81 changes: 37 additions & 44 deletions PENDING.md
Original file line number Diff line number Diff line change
@@ -1,69 +1,62 @@
## PENDING
# PENDING CHANGELOG

BREAKING CHANGES
<!----------------------------- BREAKING CHANGES ----------------------------->

* Gaia REST API
* [\#3642](https://github.com/cosmos/cosmos-sdk/pull/3642) `GET /tx/{hash}` now returns `404` instead of `500` if the transaction is not found
## BREAKING CHANGES

* Gaia CLI
### Gaia REST API

* Gaia
* [\#3641] Remove the ability to use a Keybase from the REST API client:
* `password` and `generate_only` have been removed from the `base_req` object
* All txs that used to sign or use the Keybase now only generate the tx
* `keys` routes completely removed

* SDK
* \#3580 Migrate HTTP request/response types and utilities to types/rest.
* \#3592 Drop deprecated keybase implementation's New() constructor in
favor of a new crypto/keys.New(string, string) implementation that
returns a lazy keybase instance. Remove client.MockKeyBase,
superseded by crypto/keys.NewInMemory()
* \#3621 staking.GenesisState.Bonds -> Delegations
### Gaia CLI

* Tendermint
### Gaia

FEATURES
### SDK

* Gaia REST API
### Tendermint

* Gaia CLI
<!--------------------------------- FEATURES --------------------------------->

* Gaia
## FEATURES

* SDK
### Gaia REST API

* Tendermint
### Gaia CLI

### Gaia

IMPROVEMENTS
### SDK

* Gaia REST API
### Tendermint

* Gaia CLI
<!------------------------------- IMPROVEMENTS ------------------------------->

* Gaia
## IMPROVEMENTS

* SDK
* [\#3311] Reconcile the `DecCoin/s` API with the `Coin/s` API.
* [\#3614] Add coin denom length checks to the coins constructors.
* \#3621 remove many inter-module dependancies
* [\#3601] JSON-stringify the ABCI log response which includes the log and message
index.
* [\#3604] Improve SDK funds related error messages and allow for unicode in
JSON ABCI log.
* [\#3620](https://github.com/cosmos/cosmos-sdk/pull/3620) Version command shows build tags
* [\#3638] Add Bcrypt benchmarks & justification of security parameter choice
* [\#3648] Add JSON struct tags to vesting accounts.
### Gaia REST API

* Tendermint
* [\#3618] Upgrade to Tendermint 0.30.03
### Gaia CLI

BUG FIXES
### Gaia

* Gaia REST API
### SDK

* Gaia CLI
### Tendermint

* Gaia
<!--------------------------------- BUG FIXES -------------------------------->

* SDK
* \#3646 `x/mint` now uses total token supply instead of total bonded tokens to calculate inflation
## BUG FIXES

* Tendermint
### Gaia REST API

### Gaia CLI

### Gaia

### SDK

### Tendermint
195 changes: 1 addition & 194 deletions client/keys/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,21 @@ package keys

import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
"sort"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
"github.com/cosmos/cosmos-sdk/crypto/keys"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/rest"

"errors"

"github.com/gorilla/mux"
"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/cosmos/go-bip39"
bip39 "github.com/cosmos/go-bip39"

"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/multisig"
Expand Down Expand Up @@ -304,191 +299,3 @@ func printCreate(info keys.Info, showMnemonic bool, mnemonic string) error {

return nil
}

/////////////////////////////
// REST

// function to just create a new seed to display in the UI before actually persisting it in the keybase
func generateMnemonic(algo keys.SigningAlgo) string {
kb := keys.NewInMemory()
pass := app.DefaultKeyPass
name := "inmemorykey"
_, seed, _ := kb.CreateMnemonic(name, keys.English, pass, algo)
return seed
}

// CheckAndWriteErrorResponse will check for errors and return
// a given error message when corresponding
//TODO: Move to utils/rest or similar
func CheckAndWriteErrorResponse(w http.ResponseWriter, httpErr int, err error) bool {
if err != nil {
w.WriteHeader(httpErr)
_, _ = w.Write([]byte(err.Error()))
return true
}
return false
}

// add new key REST handler
func AddNewKeyRequestHandler(indent bool) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var kb keys.Keybase
var m AddNewKey

kb, err := NewKeyBaseFromHomeFlag()
if CheckAndWriteErrorResponse(w, http.StatusInternalServerError, err) {
return
}

body, err := ioutil.ReadAll(r.Body)
if CheckAndWriteErrorResponse(w, http.StatusBadRequest, err) {
return
}

err = json.Unmarshal(body, &m)
if CheckAndWriteErrorResponse(w, http.StatusBadRequest, err) {
return
}

// Check parameters
if m.Name == "" {
CheckAndWriteErrorResponse(w, http.StatusBadRequest, errMissingName())
return
}
if m.Password == "" {
CheckAndWriteErrorResponse(w, http.StatusBadRequest, errMissingPassword())
return
}

mnemonic := m.Mnemonic
// if mnemonic is empty, generate one
if mnemonic == "" {
mnemonic = generateMnemonic(keys.Secp256k1)
}
if !bip39.IsMnemonicValid(mnemonic) {
CheckAndWriteErrorResponse(w, http.StatusBadRequest, errInvalidMnemonic())
}

if m.Account < 0 || m.Account > maxValidAccountValue {
CheckAndWriteErrorResponse(w, http.StatusBadRequest, errInvalidAccountNumber())
return
}

if m.Index < 0 || m.Index > maxValidIndexalue {
CheckAndWriteErrorResponse(w, http.StatusBadRequest, errInvalidIndexNumber())
return
}

_, err = kb.Get(m.Name)
if err == nil {
CheckAndWriteErrorResponse(w, http.StatusConflict, errKeyNameConflict(m.Name))
return
}

// create account
account := uint32(m.Account)
index := uint32(m.Index)
info, err := kb.CreateAccount(m.Name, mnemonic, keys.DefaultBIP39Passphrase, m.Password, account, index)
if CheckAndWriteErrorResponse(w, http.StatusInternalServerError, err) {
return
}

keyOutput, err := Bech32KeyOutput(info)
if CheckAndWriteErrorResponse(w, http.StatusInternalServerError, err) {
return
}

keyOutput.Mnemonic = mnemonic

rest.PostProcessResponse(w, cdc, keyOutput, indent)
}
}

// Seed REST request handler
func SeedRequestHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
algoType := vars["type"]

// algo type defaults to secp256k1
if algoType == "" {
algoType = "secp256k1"
}

algo := keys.SigningAlgo(algoType)
seed := generateMnemonic(algo)

w.Header().Set("Content-Type", "application/json")
_, _ = w.Write([]byte(seed))
}

// RecoverRequestHandler performs key recover request
func RecoverRequestHandler(indent bool) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
name := vars["name"]
var m RecoverKey

body, err := ioutil.ReadAll(r.Body)
if CheckAndWriteErrorResponse(w, http.StatusBadRequest, err) {
return
}

err = cdc.UnmarshalJSON(body, &m)
if CheckAndWriteErrorResponse(w, http.StatusBadRequest, err) {
return
}

kb, err := NewKeyBaseFromHomeFlag()
CheckAndWriteErrorResponse(w, http.StatusInternalServerError, err)

if name == "" {
CheckAndWriteErrorResponse(w, http.StatusBadRequest, errMissingName())
return
}
if m.Password == "" {
CheckAndWriteErrorResponse(w, http.StatusBadRequest, errMissingPassword())
return
}

mnemonic := m.Mnemonic
if !bip39.IsMnemonicValid(mnemonic) {
CheckAndWriteErrorResponse(w, http.StatusBadRequest, errInvalidMnemonic())
}

if m.Mnemonic == "" {
CheckAndWriteErrorResponse(w, http.StatusBadRequest, errMissingMnemonic())
return
}

if m.Account < 0 || m.Account > maxValidAccountValue {
CheckAndWriteErrorResponse(w, http.StatusBadRequest, errInvalidAccountNumber())
return
}

if m.Index < 0 || m.Index > maxValidIndexalue {
CheckAndWriteErrorResponse(w, http.StatusBadRequest, errInvalidIndexNumber())
return
}

_, err = kb.Get(name)
if err == nil {
CheckAndWriteErrorResponse(w, http.StatusConflict, errKeyNameConflict(name))
return
}

account := uint32(m.Account)
index := uint32(m.Index)

info, err := kb.CreateAccount(name, mnemonic, keys.DefaultBIP39Passphrase, m.Password, account, index)
if CheckAndWriteErrorResponse(w, http.StatusInternalServerError, err) {
return
}

keyOutput, err := Bech32KeyOutput(info)
if CheckAndWriteErrorResponse(w, http.StatusInternalServerError, err) {
return
}

rest.PostProcessResponse(w, cdc, keyOutput, indent)
}
}
Loading

0 comments on commit 6e34853

Please sign in to comment.