Skip to content

Commit

Permalink
Merge branch 'sunny/get_all_delegations_validator_querier' of https:/…
Browse files Browse the repository at this point in the history
…/github.com/cosmos/cosmos-sdk into sunny/get_all_delegations_validator_querier

Merge
  • Loading branch information
Federico Kunze committed Nov 12, 2018
2 parents 7dfeb7d + b255a7d commit a6af76e
Show file tree
Hide file tree
Showing 59 changed files with 1,342 additions and 1,068 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ FEATURES
* [cli] [\#2569](https://github.com/cosmos/cosmos-sdk/pull/2569) Add commands to query validator unbondings and redelegations
* [cli] [\#2524](https://github.com/cosmos/cosmos-sdk/issues/2524) Add support offline mode to `gaiacli tx sign`. Lookups are not performed if the flag `--offline` is on.
* [cli] [\#2558](https://github.com/cosmos/cosmos-sdk/issues/2558) Rename --print-sigs to --validate-signatures. It now performs a complete set of sanity checks and reports to the user. Also added --print-signature-only to print the signature only, not the whole transaction.
* [cli] [\#2704](https://github.com/cosmos/cosmos-sdk/pull/2704) New add-genesis-account convenience command to populate genesis.json with genesis accounts.

* SDK
* [\#1336](https://github.com/cosmos/cosmos-sdk/issues/1336) Mechanism for SDK Users to configure their own Bech32 prefixes instead of using the default cosmos prefixes.
Expand Down Expand Up @@ -47,8 +48,7 @@ BUG FIXES
* Gaia
* [\#2670](https://github.com/cosmos/cosmos-sdk/issues/2670) [x/stake] fixed incorrect `IterateBondedValidators` and split into two functions: `IterateBondedValidators` and `IterateLastBlockConsValidators`
* [\#2691](https://github.com/cosmos/cosmos-sdk/issues/2691) Fix local testnet creation by using a single canonical genesis time
- [\#2670](https://github.com/cosmos/cosmos-sdk/issues/2670) [x/stake] fixed incorrent `IterateBondedValidators` and split into two functions: `IterateBondedValidators` and `IterateLastBlockConsValidators`
- [\#2648](https://github.com/cosmos/cosmos-sdk/issues/2648) [gaiad] Fix `gaiad export` / `gaiad import` consistency, test in CI
* [\#2648](https://github.com/cosmos/cosmos-sdk/issues/2648) [gaiad] Fix `gaiad export` / `gaiad import` consistency, test in CI

* SDK
* [\#2625](https://github.com/cosmos/cosmos-sdk/issues/2625) [x/gov] fix AppendTag function usage error
Expand Down
8 changes: 4 additions & 4 deletions Gopkg.lock

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

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

[[override]]
name = "github.com/tendermint/tendermint"
version = "v0.26.1-rc0" # TODO replace w/ 0.26.1
version = "v0.26.1"

## deps without releases:

Expand Down
45 changes: 25 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation')
PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation')
VERSION := $(shell git describe --tags --long | sed 's/v\(.*\)/\1/')
BUILD_TAGS = netgo ledger
VERSION := $(subst v,,$(shell git describe --tags --long))
BUILD_TAGS = netgo
BUILD_FLAGS = -tags "${BUILD_TAGS}" -ldflags "-X github.com/cosmos/cosmos-sdk/version.Version=${VERSION}"
GCC := $(shell command -v gcc 2> /dev/null)
LEDGER_ENABLED ?= true
UNAME_S := $(shell uname -s)
GOTOOLS = \
github.com/golang/dep/cmd/dep \
github.com/alecthomas/gometalinter \
Expand All @@ -20,23 +18,30 @@ ci: get_tools get_vendor_deps install test_cover test_lint test
########################################
### Build/Install

check-ledger:
ifeq ($(LEDGER_ENABLED),true)
ifeq ($(UNAME_S),OpenBSD)
$(info "OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988)")
TMP_BUILD_TAGS := $(BUILD_TAGS)
BUILD_TAGS = $(filter-out ledger, $(TMP_BUILD_TAGS))
else
ifndef GCC
$(error "gcc not installed for ledger support, please install or set LEDGER_ENABLED to false in the Makefile")
endif
endif
else
TMP_BUILD_TAGS := $(BUILD_TAGS)
BUILD_TAGS = $(filter-out ledger, $(TMP_BUILD_TAGS))
ifeq ($(OS),Windows_NT)
GCCEXE = $(shell where gcc.exe 2> NUL)
ifeq ($(GCCEXE),)
$(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
BUILD_TAGS += ledger
endif
else
UNAME_S = $(shell uname -s)
ifeq ($(UNAME_S),OpenBSD)
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988))
else
GCC = $(shell command -v gcc 2> /dev/null)
ifeq ($(GCC),)
$(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
BUILD_TAGS += ledger
endif
endif
endif
endif

build: check-ledger update_gaia_lite_docs
build:
ifeq ($(OS),Windows_NT)
go build $(BUILD_FLAGS) -o build/gaiad.exe ./cmd/gaia/cmd/gaiad
go build $(BUILD_FLAGS) -o build/gaiacli.exe ./cmd/gaia/cmd/gaiacli
Expand Down Expand Up @@ -101,7 +106,7 @@ check_tools:

update_tools:
@echo "--> Updating tools to correct version"
./scripts/get_tools.sh
$(MAKE) -C scripts get_tools

update_dev_tools:
@echo "--> Downloading linters (this may take awhile)"
Expand All @@ -110,7 +115,7 @@ update_dev_tools:

get_tools:
@echo "--> Installing tools"
./scripts/get_tools.sh
$(MAKE) -C scripts get_tools

get_dev_tools:
@echo "--> Downloading linters (this may take awhile)"
Expand Down
10 changes: 10 additions & 0 deletions PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ BREAKING CHANGES
* Gaia REST API (`gaiacli advanced rest-server`)

* Gaia CLI (`gaiacli`)
* [cli] [\#2727](https://github.com/cosmos/cosmos-sdk/pull/2727) Fix unbonding command flow
* [cli] [\#2786](https://github.com/cosmos/cosmos-sdk/pull/2786) Fix redelegation command flow

* Gaia

* SDK
* [\#2752](https://github.com/cosmos/cosmos-sdk/pull/2752) Don't hardcode bondable denom.

* Tendermint

Expand All @@ -23,6 +26,7 @@ FEATURES
* Gaia

* SDK
* [simulator] \#2682 MsgEditValidator now looks at the validator's max rate, thus it now succeeds a significant portion of the time

* Tendermint

Expand All @@ -32,10 +36,13 @@ IMPROVEMENTS
* Gaia REST API (`gaiacli advanced rest-server`)

* Gaia CLI (`gaiacli`)
* [\#2749](https://github.com/cosmos/cosmos-sdk/pull/2749) Add --chain-id flag to gaiad testnet

* Gaia
- #2672 [Makefile] Updated for better Windows compatibility and ledger support logic, get_tools was rewritten as a cross-compatible Makefile.

* SDK
- [x/mock/simulation] [\#2720] major cleanup, introduction of helper objects, reorganization

* Tendermint

Expand All @@ -47,7 +54,10 @@ BUG FIXES
* Gaia CLI (`gaiacli`)

* Gaia
* [\#2723] Use `cosmosvalcons` Bech32 prefix in `tendermint show-address`
* [\#2742](https://github.com/cosmos/cosmos-sdk/issues/2742) Fix time format of TimeoutCommit override

* SDK

* Tendermint
* [\#2797](https://github.com/tendermint/tendermint/pull/2797) AddressBook requires addresses to have IDs; Do not crap out immediately after sending pex addrs in seed mode
29 changes: 15 additions & 14 deletions client/lcd/lcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov"
"github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/stake"
stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types"
)

func init() {
Expand Down Expand Up @@ -265,15 +266,15 @@ func TestCoinSend(t *testing.T) {
coins := acc.GetCoins()
mycoins := coins[0]

require.Equal(t, "steak", mycoins.Denom)
require.Equal(t, stakeTypes.DefaultBondDenom, mycoins.Denom)
require.Equal(t, initialBalance[0].Amount.SubRaw(1), mycoins.Amount)

// query receiver
acc = getAccount(t, port, receiveAddr)
coins = acc.GetCoins()
mycoins = coins[0]

require.Equal(t, "steak", mycoins.Denom)
require.Equal(t, stakeTypes.DefaultBondDenom, mycoins.Denom)
require.Equal(t, int64(1), mycoins.Amount.Int64())

// test failure with too little gas
Expand Down Expand Up @@ -326,7 +327,7 @@ func DisabledTestIBCTransfer(t *testing.T) {
coins := acc.GetCoins()
mycoins := coins[0]

require.Equal(t, "steak", mycoins.Denom)
require.Equal(t, stakeTypes.DefaultBondDenom, mycoins.Denom)
require.Equal(t, initialBalance[0].Amount.SubRaw(1), mycoins.Amount)

// TODO: query ibc egress packet state
Expand Down Expand Up @@ -514,7 +515,7 @@ func TestValidatorQuery(t *testing.T) {
}

func TestBonding(t *testing.T) {
name, password, denom := "test", "1234567890", "steak"
name, password, denom := "test", "1234567890", stakeTypes.DefaultBondDenom
addr, seed := CreateAddr(t, name, password, GetKeyBase(t))

cleanup, valPubKeys, operAddrs, port := InitializeTestLCD(t, 2, []sdk.AccAddress{addr})
Expand Down Expand Up @@ -568,7 +569,7 @@ func TestBonding(t *testing.T) {
// sender should have not received any coins as the unbonding has only just begun
acc = getAccount(t, port, addr)
coins = acc.GetCoins()
require.Equal(t, int64(40), coins.AmountOf("steak").Int64())
require.Equal(t, int64(40), coins.AmountOf(stakeTypes.DefaultBondDenom).Int64())

unbonding := getUndelegation(t, port, addr, operAddrs[0])
require.Equal(t, "30", unbonding.Balance.Amount.String())
Expand Down Expand Up @@ -667,11 +668,11 @@ func TestDeposit(t *testing.T) {

// query proposal
proposal = getProposal(t, port, proposalID)
require.True(t, proposal.GetTotalDeposit().IsEqual(sdk.Coins{sdk.NewInt64Coin("steak", 10)}))
require.True(t, proposal.GetTotalDeposit().IsEqual(sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 10)}))

// query deposit
deposit := getDeposit(t, port, proposalID, addr)
require.True(t, deposit.Amount.IsEqual(sdk.Coins{sdk.NewInt64Coin("steak", 10)}))
require.True(t, deposit.Amount.IsEqual(sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 10)}))
}

func TestVote(t *testing.T) {
Expand Down Expand Up @@ -865,7 +866,7 @@ func doSendWithGas(t *testing.T, port, seed, name, password string, addr sdk.Acc
sequence := acc.GetSequence()
chainID := viper.GetString(client.FlagChainID)
// send
coinbz, err := cdc.MarshalJSON(sdk.NewInt64Coin("steak", 1))
coinbz, err := cdc.MarshalJSON(sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 1))
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -951,7 +952,7 @@ func doIBCTransfer(t *testing.T, port, seed, name, password string, addr sdk.Acc
"account_number":"%d",
"sequence":"%d"
}
}`, "steak", name, password, chainID, accnum, sequence))
}`, stakeTypes.DefaultBondDenom, name, password, chainID, accnum, sequence))

res, body := Request(t, port, "POST", fmt.Sprintf("/ibc/testchain/%s/send", receiveAddr), jsonStr)
require.Equal(t, http.StatusOK, res.StatusCode, body)
Expand Down Expand Up @@ -1100,7 +1101,7 @@ func doDelegate(t *testing.T, port, seed, name, password string,
"account_number":"%d",
"sequence":"%d"
}
}`, delAddr, valAddr, "steak", amount, name, password, chainID, accnum, sequence))
}`, delAddr, valAddr, stakeTypes.DefaultBondDenom, amount, name, password, chainID, accnum, sequence))

res, body := Request(t, port, "POST", fmt.Sprintf("/stake/delegators/%s/delegations", delAddr), jsonStr)
require.Equal(t, http.StatusOK, res.StatusCode, body)
Expand Down Expand Up @@ -1354,15 +1355,15 @@ func doSubmitProposal(t *testing.T, port, seed, name, password string, proposerA
"description": "test",
"proposal_type": "Text",
"proposer": "%s",
"initial_deposit": [{ "denom": "steak", "amount": "%d" }],
"initial_deposit": [{ "denom": "%s", "amount": "%d" }],
"base_req": {
"name": "%s",
"password": "%s",
"chain_id": "%s",
"account_number":"%d",
"sequence":"%d"
}
}`, proposerAddr, amount, name, password, chainID, accnum, sequence))
}`, proposerAddr, stakeTypes.DefaultBondDenom, amount, name, password, chainID, accnum, sequence))
res, body := Request(t, port, "POST", "/gov/proposals", jsonStr)
require.Equal(t, http.StatusOK, res.StatusCode, body)

Expand All @@ -1384,15 +1385,15 @@ func doDeposit(t *testing.T, port, seed, name, password string, proposerAddr sdk
// deposit on proposal
jsonStr := []byte(fmt.Sprintf(`{
"depositer": "%s",
"amount": [{ "denom": "steak", "amount": "%d" }],
"amount": [{ "denom": "%s", "amount": "%d" }],
"base_req": {
"name": "%s",
"password": "%s",
"chain_id": "%s",
"account_number":"%d",
"sequence": "%d"
}
}`, proposerAddr, amount, name, password, chainID, accnum, sequence))
}`, proposerAddr, stakeTypes.DefaultBondDenom, amount, name, password, chainID, accnum, sequence))
res, body := Request(t, port, "POST", fmt.Sprintf("/gov/proposals/%d/deposits", proposalID), jsonStr)
require.Equal(t, http.StatusOK, res.StatusCode, body)

Expand Down
7 changes: 4 additions & 3 deletions client/lcd/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"github.com/cosmos/cosmos-sdk/x/stake"
stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types"
"github.com/tendermint/tendermint/crypto/secp256k1"
"io/ioutil"
"net"
Expand Down Expand Up @@ -227,7 +228,7 @@ func InitializeTestLCD(
msg := stake.NewMsgCreateValidator(
sdk.ValAddress(operAddr),
pubKey,
sdk.NewCoin("steak", sdk.NewInt(int64(delegation))),
sdk.NewCoin(stakeTypes.DefaultBondDenom, sdk.NewInt(int64(delegation))),
stake.Description{Moniker: fmt.Sprintf("validator-%d", i+1)},
stake.NewCommissionMsg(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()),
)
Expand All @@ -245,7 +246,7 @@ func InitializeTestLCD(
valOperAddrs = append(valOperAddrs, sdk.ValAddress(operAddr))

accAuth := auth.NewBaseAccountWithAddress(sdk.AccAddress(operAddr))
accAuth.Coins = sdk.Coins{sdk.NewInt64Coin("steak", 150)}
accAuth.Coins = sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 150)}
accs = append(accs, gapp.NewGenesisAccount(&accAuth))
}

Expand All @@ -259,7 +260,7 @@ func InitializeTestLCD(
// add some tokens to init accounts
for _, addr := range initAddrs {
accAuth := auth.NewBaseAccountWithAddress(addr)
accAuth.Coins = sdk.Coins{sdk.NewInt64Coin("steak", 100)}
accAuth.Coins = sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 100)}
acc := gapp.NewGenesisAccount(&accAuth)
genesisState.Accounts = append(genesisState.Accounts, acc)
genesisState.StakeData.Pool.LooseTokens = genesisState.StakeData.Pool.LooseTokens.Add(sdk.NewDec(100))
Expand Down
9 changes: 6 additions & 3 deletions cmd/gaia/app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ import (
"github.com/cosmos/cosmos-sdk/x/mint"
"github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/stake"
stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types"
tmtypes "github.com/tendermint/tendermint/types"
)

var (
// bonded tokens given to genesis validators/accounts
freeFermionVal = int64(100)
freeFermionsAcc = sdk.NewInt(150)
bondDenom = "steak"
bondDenom = stakeTypes.DefaultBondDenom
)

// State to Unmarshal
Expand Down Expand Up @@ -286,9 +287,11 @@ func CollectStdTxs(cdc *codec.Codec, moniker string, genTxsDir string, genDoc tm

func NewDefaultGenesisAccount(addr sdk.AccAddress) GenesisAccount {
accAuth := auth.NewBaseAccountWithAddress(addr)
accAuth.Coins = []sdk.Coin{
coins :=sdk.Coins{
{"fooToken", sdk.NewInt(1000)},
{"steak", freeFermionsAcc},
{bondDenom, freeFermionsAcc},
}
coins.Sort()
accAuth.Coins = coins
return NewGenesisAccount(&accAuth)
}
6 changes: 2 additions & 4 deletions cmd/gaia/app/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,8 @@ func TestGaiaAppGenState(t *testing.T) {
func makeMsg(name string, pk crypto.PubKey) auth.StdTx {
desc := stake.NewDescription(name, "", "", "")
comm := stakeTypes.CommissionMsg{}
msg := stake.NewMsgCreateValidator(
sdk.ValAddress(pk.Address()), pk,
sdk.NewInt64Coin(bondDenom, 50), desc, comm,
)
msg := stake.NewMsgCreateValidator(sdk.ValAddress(pk.Address()), pk, sdk.NewInt64Coin(bondDenom,
50), desc, comm)
return auth.NewStdTx([]sdk.Msg{msg}, auth.StdFee{}, nil, "")
}

Expand Down
Loading

0 comments on commit a6af76e

Please sign in to comment.