Merge branch 'develop' into jack/fix-empty-return

This commit is contained in:
Jack Zampolin 2018-12-11 08:40:08 -08:00 committed by GitHub
commit 70ce6f28f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
178 changed files with 1485 additions and 1234 deletions

View File

@ -178,7 +178,7 @@ jobs:
name: Test multi-seed Gaia simulation name: Test multi-seed Gaia simulation
command: | command: |
export PATH="$GOBIN:$PATH" export PATH="$GOBIN:$PATH"
make test_sim_gaia_multi_seed scripts/multisim.sh 25 TestFullGaiaSimulation
test_cover: test_cover:
<<: *defaults <<: *defaults

View File

@ -1,5 +1,60 @@
# Changelog # Changelog
## 0.28.0
BREAKING CHANGES
* Gaia CLI (`gaiacli`)
* [cli] [\#2595](https://github.com/cosmos/cosmos-sdk/issues/2595) Remove `keys new` in favor of `keys add` incorporating existing functionality with addition of key recovery functionality.
* [cli] [\#2987](https://github.com/cosmos/cosmos-sdk/pull/2987) Add shorthand `-a` to `gaiacli keys show` and update docs
* [cli] [\#2971](https://github.com/cosmos/cosmos-sdk/pull/2971) Additional verification when running `gaiad gentx`
* [cli] [\#2734](https://github.com/cosmos/cosmos-sdk/issues/2734) Rewrite `gaiacli config`. It is now a non-interactive config utility.
* Gaia
* [#128](https://github.com/tendermint/devops/issues/128) Updated CircleCI job to trigger website build on every push to master/develop.
* [\#2994](https://github.com/cosmos/cosmos-sdk/pull/2994) Change wrong-password error message.
* [\#3009](https://github.com/cosmos/cosmos-sdk/issues/3009) Added missing Gaia genesis verification
* [#128](https://github.com/tendermint/devops/issues/128) Updated CircleCI job to trigger website build on every push to master/develop.
* [\#2994](https://github.com/cosmos/cosmos-sdk/pull/2994) Change wrong-password error message.
* [\#3009](https://github.com/cosmos/cosmos-sdk/issues/3009) Added missing Gaia genesis verification
* [gas] [\#3052](https://github.com/cosmos/cosmos-sdk/issues/3052) Updated gas costs to more reasonable numbers
* SDK
* [auth] [\#2952](https://github.com/cosmos/cosmos-sdk/issues/2952) Signatures are no longer serialized on chain with the account number and sequence number
* [auth] [\#2952](https://github.com/cosmos/cosmos-sdk/issues/2952) Signatures are no longer serialized on chain with the account number and sequence number
* [stake] [\#3055](https://github.com/cosmos/cosmos-sdk/issues/3055) Use address instead of bond height / intratxcounter for deduplication
FEATURES
* Gaia CLI (`gaiacli`)
* [\#2961](https://github.com/cosmos/cosmos-sdk/issues/2961) Add --force flag to gaiacli keys delete command to skip passphrase check and force key deletion unconditionally.
IMPROVEMENTS
* Gaia CLI (`gaiacli`)
* [\#2991](https://github.com/cosmos/cosmos-sdk/issues/2991) Fully validate transaction signatures during `gaiacli tx sign --validate-signatures`
* SDK
* [\#1277](https://github.com/cosmos/cosmos-sdk/issues/1277) Complete bank module specification
* [\#2963](https://github.com/cosmos/cosmos-sdk/issues/2963) Complete auth module specification
* [\#2914](https://github.com/cosmos/cosmos-sdk/issues/2914) No longer withdraw validator rewards on bond/unbond, but rather move
the rewards to the respective validator's pools.
BUG FIXES
* Gaia CLI (`gaiacli`)
* [\#2921](https://github.com/cosmos/cosmos-sdk/issues/2921) Fix `keys delete` inability to delete offline and ledger keys.
* Gaia
* [\#3003](https://github.com/cosmos/cosmos-sdk/issues/3003) CollectStdTxs() must validate DelegatorAddr against genesis accounts.
* SDK
* [\#2967](https://github.com/cosmos/cosmos-sdk/issues/2967) Change ordering of `mint.BeginBlocker` and `distr.BeginBlocker`, recalculate inflation each block
* [\#3068](https://github.com/cosmos/cosmos-sdk/issues/3068) check for uint64 gas overflow during `Std#ValidateBasic`.
* [\#3071](https://github.com/cosmos/cosmos-sdk/issues/3071) Catch overflow on block gas meter
## 0.27.0 ## 0.27.0
BREAKING CHANGES BREAKING CHANGES

View File

@ -53,6 +53,7 @@ else
go build $(BUILD_FLAGS) -o build/gaiad ./cmd/gaia/cmd/gaiad go build $(BUILD_FLAGS) -o build/gaiad ./cmd/gaia/cmd/gaiad
go build $(BUILD_FLAGS) -o build/gaiacli ./cmd/gaia/cmd/gaiacli go build $(BUILD_FLAGS) -o build/gaiacli ./cmd/gaia/cmd/gaiacli
go build $(BUILD_FLAGS) -o build/gaiareplay ./cmd/gaia/cmd/gaiareplay go build $(BUILD_FLAGS) -o build/gaiareplay ./cmd/gaia/cmd/gaiareplay
go build $(BUILD_FLAGS) -o build/gaiakeyutil ./cmd/gaia/cmd/gaiakeyutil
endif endif
build-linux: build-linux:
@ -85,6 +86,7 @@ install: check-ledger update_gaia_lite_docs
go install $(BUILD_FLAGS) ./cmd/gaia/cmd/gaiad go install $(BUILD_FLAGS) ./cmd/gaia/cmd/gaiad
go install $(BUILD_FLAGS) ./cmd/gaia/cmd/gaiacli go install $(BUILD_FLAGS) ./cmd/gaia/cmd/gaiacli
go install $(BUILD_FLAGS) ./cmd/gaia/cmd/gaiareplay go install $(BUILD_FLAGS) ./cmd/gaia/cmd/gaiareplay
go install $(BUILD_FLAGS) ./cmd/gaia/cmd/gaiakeyutil
install_examples: install_examples:
go install $(BUILD_FLAGS) ./docs/examples/basecoin/cmd/basecoind go install $(BUILD_FLAGS) ./docs/examples/basecoin/cmd/basecoind
@ -184,7 +186,7 @@ test_sim_gaia_simulation_after_import:
test_sim_gaia_multi_seed: test_sim_gaia_multi_seed:
@echo "Running multi-seed Gaia simulation. This may take awhile!" @echo "Running multi-seed Gaia simulation. This may take awhile!"
@bash scripts/multisim.sh 50 TestFullGaiaSimulation @bash scripts/multisim.sh 400 TestFullGaiaSimulation
SIM_NUM_BLOCKS ?= 500 SIM_NUM_BLOCKS ?= 500
SIM_BLOCK_SIZE ?= 200 SIM_BLOCK_SIZE ?= 200

View File

@ -4,20 +4,14 @@ BREAKING CHANGES
* Gaia REST API (`gaiacli advanced rest-server`) * Gaia REST API (`gaiacli advanced rest-server`)
* [lcd] https://github.com/cosmos/cosmos-sdk/pull/3045 Fix quoted json return on GET /keys (keys list) * [lcd] https://github.com/cosmos/cosmos-sdk/pull/3045 Fix quoted json return on GET /keys (keys list)
* [gaia-lite] [\#2191](https://github.com/cosmos/cosmos-sdk/issues/2191) Split `POST /stake/delegators/{delegatorAddr}/delegations` into `POST /stake/delegators/{delegatorAddr}/delegations`, `POST /stake/delegators/{delegatorAddr}/unbonding_delegations` and `POST /stake/delegators/{delegatorAddr}/redelegations`
* [gaia-lite] [\#3056](https://github.com/cosmos/cosmos-sdk/pull/3056) `generate_only` and `simulate` have moved from query arguments to POST requests body.
* Gaia CLI (`gaiacli`) * Gaia CLI (`gaiacli`)
* [cli] [\#2595](https://github.com/cosmos/cosmos-sdk/issues/2595) Remove `keys new` in favor of `keys add` incorporating existing functionality with addition of key recovery functionality.
* [cli] [\#2987](https://github.com/cosmos/cosmos-sdk/pull/2987) Add shorthand `-a` to `gaiacli keys show` and update docs
* [cli] [\#2971](https://github.com/cosmos/cosmos-sdk/pull/2971) Additional verification when running `gaiad gentx`
* [cli] [\#2734](https://github.com/cosmos/cosmos-sdk/issues/2734) Rewrite `gaiacli config`. It is now a non-interactive config utility.
* Gaia * Gaia
- [#128](https://github.com/tendermint/devops/issues/128) Updated CircleCI job to trigger website build on every push to master/develop.
- [\#2994](https://github.com/cosmos/cosmos-sdk/pull/2994) Change wrong-password error message.
- \#3009 Added missing Gaia genesis verification
* SDK * SDK
- [auth] \#2952 Signatures are no longer serialized on chain with the account number and sequence number
* Tendermint * Tendermint
@ -27,7 +21,6 @@ FEATURES
* Gaia REST API (`gaiacli advanced rest-server`) * Gaia REST API (`gaiacli advanced rest-server`)
* Gaia CLI (`gaiacli`) * Gaia CLI (`gaiacli`)
- [\#2961](https://github.com/cosmos/cosmos-sdk/issues/2961) Add --force flag to gaiacli keys delete command to skip passphrase check and force key deletion unconditionally.
* Gaia * Gaia
@ -41,15 +34,12 @@ IMPROVEMENTS
* Gaia REST API (`gaiacli advanced rest-server`) * Gaia REST API (`gaiacli advanced rest-server`)
* Gaia CLI (`gaiacli`) * Gaia CLI (`gaiacli`)
* \#2991 Fully validate transaction signatures during `gaiacli tx sign --validate-signatures`
* Gaia * Gaia
* [\#3021](https://github.com/cosmos/cosmos-sdk/pull/3021) Add `--gentx-dir` to `gaiad collect-gentxs` to specify a directory from which collect and load gentxs.
Add `--output-document` to `gaiad init` to allow one to redirect output to file.
* SDK * SDK
- \#1277 Complete bank module specification
- \#2963 Complete auth module specification
* \#2914 No longer withdraw validator rewards on bond/unbond, but rather move
the rewards to the respective validator's pools.
* Tendermint * Tendermint
@ -59,12 +49,9 @@ BUG FIXES
* Gaia REST API (`gaiacli advanced rest-server`) * Gaia REST API (`gaiacli advanced rest-server`)
* Gaia CLI (`gaiacli`) * Gaia CLI (`gaiacli`)
* [\#2921](https://github.com/cosmos/cosmos-sdk/issues/2921) Fix `keys delete` inability to delete offline and ledger keys.
* Gaia * Gaia
* [\#3003](https://github.com/cosmos/cosmos-sdk/issues/3003) CollectStdTxs() must validate DelegatorAddr against genesis accounts.
* SDK * SDK
* \#2967 Change ordering of `mint.BeginBlocker` and `distr.BeginBlocker`, recalculate inflation each block
* Tendermint * Tendermint

View File

@ -701,6 +701,11 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte, tx sdk.Tx) (result sdk
return return
} }
var startingGas uint64
if mode == runTxModeDeliver {
startingGas = ctx.BlockGasMeter().GasConsumed()
}
defer func() { defer func() {
if r := recover(); r != nil { if r := recover(); r != nil {
switch rType := r.(type) { switch rType := r.(type) {
@ -726,6 +731,9 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte, tx sdk.Tx) (result sdk
if mode == runTxModeDeliver { if mode == runTxModeDeliver {
ctx.BlockGasMeter().ConsumeGas( ctx.BlockGasMeter().ConsumeGas(
ctx.GasMeter().GasConsumedToLimit(), "block gas meter") ctx.GasMeter().GasConsumedToLimit(), "block gas meter")
if ctx.BlockGasMeter().GasConsumed() < startingGas {
panic(sdk.ErrorGasOverflow{"tx gas summation"})
}
} }
}() }()

View File

@ -1,10 +1,11 @@
package baseapp package baseapp
import ( import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/tendermint/tendermint/abci/server" "github.com/tendermint/tendermint/abci/server"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tendermint/libs/common" cmn "github.com/tendermint/tendermint/libs/common"
sdk "github.com/cosmos/cosmos-sdk/types"
) )
// nolint - Mostly for testing // nolint - Mostly for testing

View File

@ -4,9 +4,10 @@ package baseapp
import ( import (
"fmt" "fmt"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/cosmos/cosmos-sdk/store" "github.com/cosmos/cosmos-sdk/store"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
dbm "github.com/tendermint/tendermint/libs/db"
) )
// File for storing in-package BaseApp optional functions, // File for storing in-package BaseApp optional functions,

View File

@ -4,9 +4,10 @@ import (
"fmt" "fmt"
"testing" "testing"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
sdk "github.com/cosmos/cosmos-sdk/types"
) )
// Test that we can only query from the latest committed state. // Test that we can only query from the latest committed state.

View File

@ -7,9 +7,10 @@ import (
"path" "path"
"strconv" "strconv"
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
"github.com/tendermint/tendermint/libs/cli" "github.com/tendermint/tendermint/libs/cli"
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
"github.com/pelletier/go-toml" "github.com/pelletier/go-toml"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"

View File

@ -13,14 +13,15 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/cosmos/cosmos-sdk/client/keys"
cskeys "github.com/cosmos/cosmos-sdk/crypto/keys"
"github.com/cosmos/cosmos-sdk/types"
"github.com/tendermint/tendermint/libs/cli" "github.com/tendermint/tendermint/libs/cli"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
tmlite "github.com/tendermint/tendermint/lite" tmlite "github.com/tendermint/tendermint/lite"
tmliteProxy "github.com/tendermint/tendermint/lite/proxy" tmliteProxy "github.com/tendermint/tendermint/lite/proxy"
rpcclient "github.com/tendermint/tendermint/rpc/client" rpcclient "github.com/tendermint/tendermint/rpc/client"
"github.com/cosmos/cosmos-sdk/client/keys"
cskeys "github.com/cosmos/cosmos-sdk/crypto/keys"
"github.com/cosmos/cosmos-sdk/types"
) )
const ctxAccStoreName = "acc" const ctxAccStoreName = "acc"
@ -46,7 +47,7 @@ type CLIContext struct {
JSON bool JSON bool
PrintResponse bool PrintResponse bool
Verifier tmlite.Verifier Verifier tmlite.Verifier
DryRun bool Simulate bool
GenerateOnly bool GenerateOnly bool
fromAddress types.AccAddress fromAddress types.AccAddress
fromName string fromName string
@ -84,7 +85,7 @@ func NewCLIContext() CLIContext {
JSON: viper.GetBool(client.FlagJson), JSON: viper.GetBool(client.FlagJson),
PrintResponse: viper.GetBool(client.FlagPrintResponse), PrintResponse: viper.GetBool(client.FlagPrintResponse),
Verifier: verifier, Verifier: verifier,
DryRun: viper.GetBool(client.FlagDryRun), Simulate: viper.GetBool(client.FlagDryRun),
GenerateOnly: viper.GetBool(client.FlagGenerateOnly), GenerateOnly: viper.GetBool(client.FlagGenerateOnly),
fromAddress: fromAddress, fromAddress: fromAddress,
fromName: fromName, fromName: fromName,
@ -243,3 +244,15 @@ func (ctx CLIContext) WithVerifier(verifier tmlite.Verifier) CLIContext {
ctx.Verifier = verifier ctx.Verifier = verifier
return ctx return ctx
} }
// WithGenerateOnly returns a copy of the context with updated GenerateOnly value
func (ctx CLIContext) WithGenerateOnly(generateOnly bool) CLIContext {
ctx.GenerateOnly = generateOnly
return ctx
}
// WithSimulation returns a copy of the context with updated Simulate value
func (ctx CLIContext) WithSimulation(simulate bool) CLIContext {
ctx.Simulate = simulate
return ctx
}

View File

@ -1,8 +1,9 @@
package context package context
import ( import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/pkg/errors" "github.com/pkg/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
) )
// ErrInvalidAccount returns a standardized error reflecting that a given // ErrInvalidAccount returns a standardized error reflecting that a given

View File

@ -10,7 +10,6 @@ import (
"strings" "strings"
"github.com/cosmos/cosmos-sdk/store"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto/merkle" "github.com/tendermint/tendermint/crypto/merkle"
cmn "github.com/tendermint/tendermint/libs/common" cmn "github.com/tendermint/tendermint/libs/common"
@ -18,6 +17,8 @@ import (
tmliteProxy "github.com/tendermint/tendermint/lite/proxy" tmliteProxy "github.com/tendermint/tendermint/lite/proxy"
rpcclient "github.com/tendermint/tendermint/rpc/client" rpcclient "github.com/tendermint/tendermint/rpc/client"
tmtypes "github.com/tendermint/tendermint/types" tmtypes "github.com/tendermint/tendermint/types"
"github.com/cosmos/cosmos-sdk/store"
) )
// GetNode returns an RPC client. If the context's client is not defined, an // GetNode returns an RPC client. If the context's client is not defined, an

View File

@ -43,6 +43,7 @@ const (
FlagSSLHosts = "ssl-hosts" FlagSSLHosts = "ssl-hosts"
FlagSSLCertFile = "ssl-certfile" FlagSSLCertFile = "ssl-certfile"
FlagSSLKeyFile = "ssl-keyfile" FlagSSLKeyFile = "ssl-keyfile"
FlagOutputDocument = "output-document" // inspired by wget -O
) )
// LineBreak can be included in a command list to provide a blank line // LineBreak can be included in a command list to provide a blank line

View File

@ -1,8 +1,9 @@
package client package client
import ( import (
"github.com/cosmos/cosmos-sdk/crypto/keys"
dbm "github.com/tendermint/tendermint/libs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/cosmos/cosmos-sdk/crypto/keys"
) )
// GetKeyBase initializes a keybase based on the given db. // GetKeyBase initializes a keybase based on the given db.

View File

@ -10,10 +10,11 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/gorilla/mux"
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
keys "github.com/cosmos/cosmos-sdk/crypto/keys" keys "github.com/cosmos/cosmos-sdk/crypto/keys"
keyerror "github.com/cosmos/cosmos-sdk/crypto/keys/keyerror" keyerror "github.com/cosmos/cosmos-sdk/crypto/keys/keyerror"
"github.com/gorilla/mux"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )

View File

@ -4,9 +4,10 @@ import (
"crypto/sha256" "crypto/sha256"
"fmt" "fmt"
"github.com/cosmos/cosmos-sdk/client"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client"
bip39 "github.com/bartekn/go-bip39" bip39 "github.com/bartekn/go-bip39"
) )

View File

@ -1,9 +1,10 @@
package keys package keys
import ( import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client"
) )
// Commands registers a sub-tree of commands to interact with // Commands registers a sub-tree of commands to interact with

View File

@ -4,17 +4,19 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"github.com/cosmos/cosmos-sdk/crypto/keys"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
"github.com/cosmos/cosmos-sdk/crypto/keys/keyerror" "github.com/cosmos/cosmos-sdk/crypto/keys"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/tendermint/tendermint/crypto/multisig" "github.com/tendermint/tendermint/crypto/multisig"
"github.com/tendermint/tendermint/libs/cli" "github.com/tendermint/tendermint/libs/cli"
"github.com/cosmos/cosmos-sdk/crypto/keys/keyerror"
sdk "github.com/cosmos/cosmos-sdk/types"
) )
const ( const (

View File

@ -5,12 +5,14 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"github.com/cosmos/cosmos-sdk/client"
keys "github.com/cosmos/cosmos-sdk/crypto/keys"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/cosmos/cosmos-sdk/crypto/keys/keyerror" "github.com/cosmos/cosmos-sdk/client"
keys "github.com/cosmos/cosmos-sdk/crypto/keys"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/crypto/keys/keyerror"
) )
func updateKeyCommand() *cobra.Command { func updateKeyCommand() *cobra.Command {

View File

@ -5,14 +5,15 @@ import (
"net/http" "net/http"
"path/filepath" "path/filepath"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/syndtr/goleveldb/leveldb/opt" "github.com/syndtr/goleveldb/leveldb/opt"
"github.com/tendermint/tendermint/libs/cli" "github.com/tendermint/tendermint/libs/cli"
dbm "github.com/tendermint/tendermint/libs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys"
sdk "github.com/cosmos/cosmos-sdk/types"
) )
// KeyDBName is the directory under root where we store the keys // KeyDBName is the directory under root where we store the keys

View File

@ -1,11 +1,13 @@
package keys package keys
import ( import (
"github.com/cosmos/cosmos-sdk/crypto/keys"
"github.com/stretchr/testify/require"
"io/ioutil" "io/ioutil"
"os" "os"
"testing" "testing"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/crypto/keys"
) )
func TestGetKeyBaseLocks(t *testing.T) { func TestGetKeyBaseLocks(t *testing.T) {

View File

@ -279,29 +279,29 @@ func TestCoinSend(t *testing.T) {
require.Equal(t, int64(1), mycoins.Amount.Int64()) require.Equal(t, int64(1), mycoins.Amount.Int64())
// test failure with too little gas // test failure with too little gas
res, body, _ = doSendWithGas(t, port, seed, name, password, addr, "100", 0, "") res, body, _ = doSendWithGas(t, port, seed, name, password, addr, "100", 0, false, false)
require.Equal(t, http.StatusInternalServerError, res.StatusCode, body) require.Equal(t, http.StatusInternalServerError, res.StatusCode, body)
// test failure with negative gas // test failure with negative gas
res, body, _ = doSendWithGas(t, port, seed, name, password, addr, "-200", 0, "") res, body, _ = doSendWithGas(t, port, seed, name, password, addr, "-200", 0, false, false)
require.Equal(t, http.StatusBadRequest, res.StatusCode, body) require.Equal(t, http.StatusBadRequest, res.StatusCode, body)
// test failure with 0 gas // test failure with 0 gas
res, body, _ = doSendWithGas(t, port, seed, name, password, addr, "0", 0, "") res, body, _ = doSendWithGas(t, port, seed, name, password, addr, "0", 0, false, false)
require.Equal(t, http.StatusInternalServerError, res.StatusCode, body) require.Equal(t, http.StatusInternalServerError, res.StatusCode, body)
// test failure with wrong adjustment // test failure with wrong adjustment
res, body, _ = doSendWithGas(t, port, seed, name, password, addr, "simulate", 0.1, "") res, body, _ = doSendWithGas(t, port, seed, name, password, addr, "simulate", 0.1, false, false)
require.Equal(t, http.StatusInternalServerError, res.StatusCode, body) require.Equal(t, http.StatusInternalServerError, res.StatusCode, body)
// run simulation and test success with estimated gas // run simulation and test success with estimated gas
res, body, _ = doSendWithGas(t, port, seed, name, password, addr, "", 0, "?simulate=true") res, body, _ = doSendWithGas(t, port, seed, name, password, addr, "", 0, true, false)
require.Equal(t, http.StatusOK, res.StatusCode, body) require.Equal(t, http.StatusOK, res.StatusCode, body)
var responseBody struct { var responseBody struct {
GasEstimate int64 `json:"gas_estimate"` GasEstimate int64 `json:"gas_estimate"`
} }
require.Nil(t, json.Unmarshal([]byte(body), &responseBody)) require.Nil(t, json.Unmarshal([]byte(body), &responseBody))
res, body, _ = doSendWithGas(t, port, seed, name, password, addr, fmt.Sprintf("%v", responseBody.GasEstimate), 0, "") res, body, _ = doSendWithGas(t, port, seed, name, password, addr, fmt.Sprintf("%v", responseBody.GasEstimate), 0, false, false)
require.Equal(t, http.StatusOK, res.StatusCode, body) require.Equal(t, http.StatusOK, res.StatusCode, body)
} }
@ -342,7 +342,7 @@ func TestCoinSendGenerateSignAndBroadcast(t *testing.T) {
acc := getAccount(t, port, addr) acc := getAccount(t, port, addr)
// generate TX // generate TX
res, body, _ := doSendWithGas(t, port, seed, name, password, addr, "simulate", 0, "?generate_only=true") res, body, _ := doSendWithGas(t, port, seed, name, "", addr, "simulate", 0, false, true)
require.Equal(t, http.StatusOK, res.StatusCode, body) require.Equal(t, http.StatusOK, res.StatusCode, body)
var msg auth.StdTx var msg auth.StdTx
require.Nil(t, cdc.UnmarshalJSON([]byte(body), &msg)) require.Nil(t, cdc.UnmarshalJSON([]byte(body), &msg))
@ -897,7 +897,9 @@ func getAccount(t *testing.T, port string, addr sdk.AccAddress) auth.Account {
return acc return acc
} }
func doSendWithGas(t *testing.T, port, seed, name, password string, addr sdk.AccAddress, gas string, gasAdjustment float64, queryStr string) (res *http.Response, body string, receiveAddr sdk.AccAddress) { func doSendWithGas(t *testing.T, port, seed, name, password string, addr sdk.AccAddress, gas string,
gasAdjustment float64, simulate, generateOnly bool) (
res *http.Response, body string, receiveAddr sdk.AccAddress) {
// create receive address // create receive address
kb := client.MockKeyBase() kb := client.MockKeyBase()
@ -935,11 +937,13 @@ func doSendWithGas(t *testing.T, port, seed, name, password string, addr sdk.Acc
"password": "%s", "password": "%s",
"chain_id": "%s", "chain_id": "%s",
"account_number":"%d", "account_number":"%d",
"sequence":"%d" "sequence": "%d",
"simulate": %v,
"generate_only": %v
} }
}`, coinbz, gasStr, gasAdjustmentStr, name, password, chainID, accnum, sequence)) }`, coinbz, gasStr, gasAdjustmentStr, name, password, chainID, accnum, sequence, simulate, generateOnly))
res, body = Request(t, port, "POST", fmt.Sprintf("/bank/accounts/%s/transfers%v", receiveAddr, queryStr), jsonStr) res, body = Request(t, port, "POST", fmt.Sprintf("/bank/accounts/%s/transfers", receiveAddr), jsonStr)
return return
} }
@ -958,7 +962,7 @@ func doRecoverKey(t *testing.T, port, recoverName, recoverPassword, seed string)
} }
func doSend(t *testing.T, port, seed, name, password string, addr sdk.AccAddress) (receiveAddr sdk.AccAddress, resultTx ctypes.ResultBroadcastTxCommit) { func doSend(t *testing.T, port, seed, name, password string, addr sdk.AccAddress) (receiveAddr sdk.AccAddress, resultTx ctypes.ResultBroadcastTxCommit) {
res, body, receiveAddr := doSendWithGas(t, port, seed, name, password, addr, "", 0, "") res, body, receiveAddr := doSendWithGas(t, port, seed, name, password, addr, "", 0, false, false)
require.Equal(t, http.StatusOK, res.StatusCode, body) require.Equal(t, http.StatusOK, res.StatusCode, body)
err := cdc.UnmarshalJSON([]byte(body), &resultTx) err := cdc.UnmarshalJSON([]byte(body), &resultTx)
@ -1172,15 +1176,9 @@ func doDelegate(t *testing.T, port, seed, name, password string,
chainID := viper.GetString(client.FlagChainID) chainID := viper.GetString(client.FlagChainID)
jsonStr := []byte(fmt.Sprintf(`{ jsonStr := []byte(fmt.Sprintf(`{
"delegations": [ "delegator_addr": "%s",
{ "validator_addr": "%s",
"delegator_addr": "%s", "delegation": { "denom": "%s", "amount": "%d" },
"validator_addr": "%s",
"delegation": { "denom": "%s", "amount": "%d" }
}
],
"begin_unbondings": [],
"begin_redelegates": [],
"base_req": { "base_req": {
"name": "%s", "name": "%s",
"password": "%s", "password": "%s",
@ -1193,11 +1191,10 @@ func doDelegate(t *testing.T, port, seed, name, password string,
res, body := Request(t, port, "POST", fmt.Sprintf("/stake/delegators/%s/delegations", delAddr), jsonStr) res, body := Request(t, port, "POST", fmt.Sprintf("/stake/delegators/%s/delegations", delAddr), jsonStr)
require.Equal(t, http.StatusOK, res.StatusCode, body) require.Equal(t, http.StatusOK, res.StatusCode, body)
var results []ctypes.ResultBroadcastTxCommit err := cdc.UnmarshalJSON([]byte(body), &resultTx)
err := cdc.UnmarshalJSON([]byte(body), &results)
require.Nil(t, err) require.Nil(t, err)
return results[0] return
} }
func doBeginUnbonding(t *testing.T, port, seed, name, password string, func doBeginUnbonding(t *testing.T, port, seed, name, password string,
@ -1209,15 +1206,9 @@ func doBeginUnbonding(t *testing.T, port, seed, name, password string,
chainID := viper.GetString(client.FlagChainID) chainID := viper.GetString(client.FlagChainID)
jsonStr := []byte(fmt.Sprintf(`{ jsonStr := []byte(fmt.Sprintf(`{
"delegations": [], "delegator_addr": "%s",
"begin_unbondings": [ "validator_addr": "%s",
{ "shares": "%d",
"delegator_addr": "%s",
"validator_addr": "%s",
"shares": "%d"
}
],
"begin_redelegates": [],
"base_req": { "base_req": {
"name": "%s", "name": "%s",
"password": "%s", "password": "%s",
@ -1227,14 +1218,13 @@ func doBeginUnbonding(t *testing.T, port, seed, name, password string,
} }
}`, delAddr, valAddr, amount, name, password, chainID, accnum, sequence)) }`, delAddr, valAddr, amount, name, password, chainID, accnum, sequence))
res, body := Request(t, port, "POST", fmt.Sprintf("/stake/delegators/%s/delegations", delAddr), jsonStr) res, body := Request(t, port, "POST", fmt.Sprintf("/stake/delegators/%s/unbonding_delegations", delAddr), jsonStr)
require.Equal(t, http.StatusOK, res.StatusCode, body) require.Equal(t, http.StatusOK, res.StatusCode, body)
var results []ctypes.ResultBroadcastTxCommit err := cdc.UnmarshalJSON([]byte(body), &resultTx)
err := cdc.UnmarshalJSON([]byte(body), &results)
require.Nil(t, err) require.Nil(t, err)
return results[0] return
} }
func doBeginRedelegation(t *testing.T, port, seed, name, password string, func doBeginRedelegation(t *testing.T, port, seed, name, password string,
@ -1247,16 +1237,10 @@ func doBeginRedelegation(t *testing.T, port, seed, name, password string,
chainID := viper.GetString(client.FlagChainID) chainID := viper.GetString(client.FlagChainID)
jsonStr := []byte(fmt.Sprintf(`{ jsonStr := []byte(fmt.Sprintf(`{
"delegations": [], "delegator_addr": "%s",
"begin_unbondings": [], "validator_src_addr": "%s",
"begin_redelegates": [ "validator_dst_addr": "%s",
{ "shares": "%d",
"delegator_addr": "%s",
"validator_src_addr": "%s",
"validator_dst_addr": "%s",
"shares": "%d"
}
],
"base_req": { "base_req": {
"name": "%s", "name": "%s",
"password": "%s", "password": "%s",
@ -1266,14 +1250,13 @@ func doBeginRedelegation(t *testing.T, port, seed, name, password string,
} }
}`, delAddr, valSrcAddr, valDstAddr, amount, name, password, chainID, accnum, sequence)) }`, delAddr, valSrcAddr, valDstAddr, amount, name, password, chainID, accnum, sequence))
res, body := Request(t, port, "POST", fmt.Sprintf("/stake/delegators/%s/delegations", delAddr), jsonStr) res, body := Request(t, port, "POST", fmt.Sprintf("/stake/delegators/%s/redelegations", delAddr), jsonStr)
require.Equal(t, http.StatusOK, res.StatusCode, body) require.Equal(t, http.StatusOK, res.StatusCode, body)
var results []ctypes.ResultBroadcastTxCommit err := cdc.UnmarshalJSON([]byte(body), &resultTx)
err := cdc.UnmarshalJSON([]byte(body), &results)
require.Nil(t, err) require.Nil(t, err)
return results[0] return
} }
func getValidators(t *testing.T, port string) []stake.Validator { func getValidators(t *testing.T, port string) []stake.Validator {

View File

@ -7,12 +7,6 @@ import (
"net/http" "net/http"
"os" "os"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/codec"
keybase "github.com/cosmos/cosmos-sdk/crypto/keys"
"github.com/cosmos/cosmos-sdk/server"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/rakyll/statik/fs" "github.com/rakyll/statik/fs"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -20,6 +14,13 @@ import (
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
rpcserver "github.com/tendermint/tendermint/rpc/lib/server" rpcserver "github.com/tendermint/tendermint/rpc/lib/server"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/codec"
keybase "github.com/cosmos/cosmos-sdk/crypto/keys"
"github.com/cosmos/cosmos-sdk/server"
// Import statik for light client stuff // Import statik for light client stuff
_ "github.com/cosmos/cosmos-sdk/client/lcd/statik" _ "github.com/cosmos/cosmos-sdk/client/lcd/statik"
) )

View File

@ -376,16 +376,6 @@ paths:
produces: produces:
- application/json - application/json
parameters: parameters:
- in: query
name: simulate
description: if true, ignore the gas field and perform a simulation of a transaction, but don't broadcast it
required: false
type: boolean
- in: query
name: generate_only
description: if true, build an unsigned transaction and write it back
required: false
type: boolean
- in: path - in: path
name: address name: address
description: Account address in bech32 format description: Account address in bech32 format
@ -635,81 +625,6 @@ paths:
description: Bech32 AccAddress of Delegator description: Bech32 AccAddress of Delegator
required: true required: true
type: string type: string
post:
summary: Submit delegation
parameters:
- in: query
name: simulate
description: if true, ignore the gas field and perform a simulation of a transaction, but don't broadcast it
required: false
type: boolean
- in: query
name: generate_only
description: if true, build an unsigned transaction and write it back
required: false
type: boolean
- in: body
name: delegation
description: The password of the account to remove from the KMS
schema:
type: object
properties:
base_req:
"$ref": "#/definitions/BaseReq"
delegations:
type: array
items:
type: object
properties:
delegator_addr:
$ref: "#/definitions/Address"
validator_addr:
$ref: "#/definitions/ValidatorAddress"
delegation:
$ref: "#/definitions/Coin"
begin_unbondings:
type: array
items:
type: object
properties:
delegator_addr:
$ref: "#/definitions/Address"
validator_addr:
$ref: "#/definitions/ValidatorAddress"
shares:
type: string
example: "100"
begin_redelegates:
type: array
items:
type: object
properties:
delegator_addr:
$ref: "#/definitions/Address"
validator_src_addr:
$ref: "#/definitions/ValidatorAddress"
validator_dst_addr:
$ref: "#/definitions/ValidatorAddress"
shares:
type: string
example: "100"
tags:
- ICS21
consumes:
- application/json
produces:
- application/json
responses:
200:
description: OK
schema:
$ref: "#/definitions/BroadcastTxCommitResult"
400:
description: Invalid delegator address or delegation body
401:
description: Key password is wrong
500:
description: Internal Server Error
get: get:
summary: Get all delegations from a delegator summary: Get all delegations from a delegator
tags: tags:
@ -722,12 +637,72 @@ paths:
schema: schema:
type: array type: array
items: items:
type: object $ref: "#/definitions/Delegation"
"$ref": "#/definitions/Delegation"
400: 400:
description: Invalid delegator address description: Invalid delegator address
500: 500:
description: Internal Server Error description: Internal Server Error
post:
summary: Submit delegation
parameters:
- in: body
name: delegation
description: The password of the account to remove from the KMS
schema:
type: object
properties:
base_req:
$ref: "#/definitions/BaseReq"
delegator_addr:
$ref: "#/definitions/Address"
validator_addr:
$ref: "#/definitions/ValidatorAddress"
delegation:
$ref: "#/definitions/Coin"
tags:
- ICS21
consumes:
- application/json
produces:
- application/json
responses:
200:
description: OK
schema:
$ref: "#/definitions/BroadcastTxCommitResult"
400:
description: Invalid delegator address or delegation request body
401:
description: Key password is wrong
500:
description: Internal Server Error
/stake/delegators/{delegatorAddr}/delegations/{validatorAddr}:
parameters:
- in: path
name: delegatorAddr
description: Bech32 AccAddress of Delegator
required: true
type: string
- in: path
name: validatorAddr
description: Bech32 OperatorAddress of validator
required: true
type: string
get:
summary: Query the current delegation between a delegator and a validator
tags:
- ICS21
produces:
- application/json
responses:
200:
description: OK
schema:
$ref: "#/definitions/Delegation"
400:
description: Invalid delegator address or validator address
500:
description: Internal Server Error
/stake/delegators/{delegatorAddr}/unbonding_delegations: /stake/delegators/{delegatorAddr}/unbonding_delegations:
parameters: parameters:
- in: path - in: path
@ -747,12 +722,85 @@ paths:
schema: schema:
type: array type: array
items: items:
type: object $ref: "#/definitions/UnbondingDelegation"
"$ref": "#/definitions/UnbondingDelegation"
400: 400:
description: Invalid delegator address description: Invalid delegator address
500: 500:
description: Internal Server Error description: Internal Server Error
post:
summary: Submit an unbonding delegation
parameters:
- in: query
name: simulate
description: if true, ignore the gas field and perform a simulation of a transaction, but don't broadcast it
required: false
type: boolean
- in: query
name: generate_only
description: if true, build an unsigned transaction and write it back
required: false
type: boolean
- in: body
name: delegation
description: The password of the account to remove from the KMS
schema:
type: object
properties:
base_req:
$ref: "#/definitions/BaseReq"
delegator_addr:
$ref: "#/definitions/Address"
validator_addr:
$ref: "#/definitions/ValidatorAddress"
shares:
type: string
example: "100"
tags:
- ICS21
consumes:
- application/json
produces:
- application/json
responses:
200:
description: OK
schema:
$ref: "#/definitions/BroadcastTxCommitResult"
400:
description: Invalid delegator address or unbonding delegation request body
401:
description: Key password is wrong
500:
description: Internal Server Error
/stake/delegators/{delegatorAddr}/unbonding_delegations/{validatorAddr}:
parameters:
- in: path
name: delegatorAddr
description: Bech32 AccAddress of Delegator
required: true
type: string
- in: path
name: validatorAddr
description: Bech32 OperatorAddress of validator
required: true
type: string
get:
summary: Query all unbonding delegations between a delegator and a validator
tags:
- ICS21
produces:
- application/json
responses:
200:
description: OK
schema:
type: array
items:
$ref: "#/definitions/UnbondingDelegation"
400:
description: Invalid delegator address or validator address
500:
description: Internal Server Error
/stake/delegators/{delegatorAddr}/redelegations: /stake/delegators/{delegatorAddr}/redelegations:
parameters: parameters:
- in: path - in: path
@ -772,12 +820,58 @@ paths:
schema: schema:
type: array type: array
items: items:
type: object $ref: "#/definitions/Redelegation"
"$ref": "#/definitions/Redelegation"
400: 400:
description: Invalid delegator address description: Invalid delegator address
500: 500:
description: Internal Server Error description: Internal Server Error
post:
summary: Submit a redelegation
parameters:
- in: query
name: simulate
description: if true, ignore the gas field and perform a simulation of a transaction, but don't broadcast it
required: false
type: boolean
- in: query
name: generate_only
description: if true, build an unsigned transaction and write it back
required: false
type: boolean
- in: body
name: delegation
description: The password of the account to remove from the KMS
schema:
type: object
properties:
base_req:
$ref: "#/definitions/BaseReq"
delegator_addr:
$ref: "#/definitions/Address"
validator_src_addr:
$ref: "#/definitions/ValidatorAddress"
validator_dst_addr:
$ref: "#/definitions/ValidatorAddress"
shares:
type: string
example: "100"
tags:
- ICS21
consumes:
- application/json
produces:
- application/json
responses:
200:
description: OK
schema:
$ref: "#/definitions/BroadcastTxCommitResult"
400:
description: Invalid delegator address or redelegation request body
401:
description: Key password is wrong
500:
description: Internal Server Error
/stake/delegators/{delegatorAddr}/validators: /stake/delegators/{delegatorAddr}/validators:
parameters: parameters:
- in: path - in: path
@ -855,63 +949,6 @@ paths:
description: Invalid delegator address description: Invalid delegator address
500: 500:
description: Internal Server Error description: Internal Server Error
/stake/delegators/{delegatorAddr}/delegations/{validatorAddr}:
parameters:
- in: path
name: delegatorAddr
description: Bech32 AccAddress of Delegator
required: true
type: string
- in: path
name: validatorAddr
description: Bech32 OperatorAddress of validator
required: true
type: string
get:
summary: Query the current delegation between a delegator and a validator
tags:
- ICS21
produces:
- application/json
responses:
200:
description: OK
schema:
$ref: "#/definitions/Delegation"
400:
description: Invalid delegator address or validator address
500:
description: Internal Server Error
/stake/delegators/{delegatorAddr}/unbonding_delegations/{validatorAddr}:
parameters:
- in: path
name: delegatorAddr
description: Bech32 AccAddress of Delegator
required: true
type: string
- in: path
name: validatorAddr
description: Bech32 OperatorAddress of validator
required: true
type: string
get:
summary: Query all unbonding delegations between a delegator and a validator
tags:
- ICS21
produces:
- application/json
responses:
200:
description: OK
schema:
type: array
items:
type: object
"$ref": "#/definitions/UnbondingDelegation"
400:
description: Invalid delegator address or validator address
500:
description: Internal Server Error
/stake/validators: /stake/validators:
get: get:
summary: Get all validator candidates summary: Get all validator candidates
@ -1123,16 +1160,6 @@ paths:
tags: tags:
- ICS23 - ICS23
parameters: parameters:
- in: query
name: simulate
description: if true, ignore the gas field and perform a simulation of a transaction, but don't broadcast it
required: false
type: boolean
- in: query
name: generate_only
description: if true, build an unsigned transaction and write it back
required: false
type: boolean
- type: string - type: string
description: Bech32 validator address description: Bech32 validator address
name: validatorAddr name: validatorAddr
@ -1146,7 +1173,7 @@ paths:
type: object type: object
properties: properties:
base_req: base_req:
"$ref": "#/definitions/BaseReq" $ref: "#/definitions/BaseReq"
responses: responses:
200: 200:
description: OK description: OK
@ -1169,16 +1196,6 @@ paths:
tags: tags:
- ICS22 - ICS22
parameters: parameters:
- in: query
name: simulate
description: if true, ignore the gas field and perform a simulation of a transaction, but don't broadcast it
required: false
type: boolean
- in: query
name: generate_only
description: if true, build an unsigned transaction and write it back
required: false
type: boolean
- description: valid value of `"proposal_type"` can be `"text"`, `"parameter_change"`, `"software_upgrade"` - description: valid value of `"proposal_type"` can be `"text"`, `"parameter_change"`, `"software_upgrade"`
name: post_proposal_body name: post_proposal_body
in: body in: body
@ -1187,7 +1204,7 @@ paths:
type: object type: object
properties: properties:
base_req: base_req:
"$ref": "#/definitions/BaseReq" $ref: "#/definitions/BaseReq"
title: title:
type: string type: string
description: description:
@ -1196,7 +1213,7 @@ paths:
type: string type: string
example: "text" example: "text"
proposer: proposer:
"$ref": "#/definitions/Address" $ref: "#/definitions/Address"
initial_deposit: initial_deposit:
type: array type: array
items: items:
@ -1205,7 +1222,7 @@ paths:
200: 200:
description: OK description: OK
schema: schema:
"$ref": "#/definitions/BroadcastTxCommitResult" $ref: "#/definitions/BroadcastTxCommitResult"
400: 400:
description: Invalid proposal body description: Invalid proposal body
401: 401:
@ -1241,184 +1258,11 @@ paths:
schema: schema:
type: array type: array
items: items:
"$ref": "#/definitions/TextProposal" $ref: "#/definitions/TextProposal"
400: 400:
description: Invalid query parameters description: Invalid query parameters
500: 500:
description: Internal Server Error description: Internal Server Error
/gov/proposals/{proposalId}/deposits:
post:
summary: Deposit tokens to a proposal
description: Send transaction to deposit tokens to a proposal
consumes:
- application/json
produces:
- application/json
tags:
- ICS22
parameters:
- in: query
name: simulate
description: if true, ignore the gas field and perform a simulation of a transaction, but don't broadcast it
required: false
type: boolean
- in: query
name: generate_only
description: if true, build an unsigned transaction and write it back
required: false
type: boolean
- type: string
description: proposal id
name: proposalId
required: true
in: path
- description: ''
name: post_deposit_body
in: body
required: true
schema:
type: object
properties:
base_req:
"$ref": "#/definitions/BaseReq"
depositor:
"$ref": "#/definitions/Address"
amount:
type: array
items:
$ref: "#/definitions/Coin"
responses:
200:
description: OK
schema:
"$ref": "#/definitions/BroadcastTxCommitResult"
400:
description: Invalid proposal id or deposit body
401:
description: Key password is wrong
500:
description: Internal Server Error
get:
summary: Query deposits
description: Query deposits by proposalId
produces:
- application/json
tags:
- ICS22
parameters:
- type: string
name: proposalId
required: true
in: path
responses:
200:
description: OK
schema:
type: array
items:
"$ref": "#/definitions/Deposit"
400:
description: Invalid proposal id
500:
description: Internal Server Error
/gov/proposals/{proposalId}/tally:
get:
summary: Get a proposal's tally result at the current time
description: Gets a proposal's tally result at the current time. If the proposal is pending deposits (i.e status 'DepositPeriod') it returns an empty tally result.
produces:
- application/json
tags:
- ICS22
parameters:
- type: string
description: proposal id
name: proposalId
required: true
in: path
responses:
200:
description: OK
schema:
$ref: "#/definitions/TallyResult"
400:
description: Invalid proposal id
500:
description: Internal Server Error
/gov/proposals/{proposalId}/votes:
post:
summary: Vote a proposal
description: Send transaction to vote a proposal
consumes:
- application/json
produces:
- application/json
tags:
- ICS22
parameters:
- in: query
name: simulate
description: if true, ignore the gas field and perform a simulation of a transaction, but don't broadcast it
required: false
type: boolean
- in: query
name: generate_only
description: if true, build an unsigned transaction and write it back
required: false
type: boolean
- type: string
description: proposal id
name: proposalId
required: true
in: path
- description: valid value of `"option"` field can be `"yes"`, `"no"`, `"no_with_veto"` and `"abstain"`
name: post_vote_body
in: body
required: true
schema:
type: object
properties:
base_req:
"$ref": "#/definitions/BaseReq"
voter:
"$ref": "#/definitions/Address"
option:
type: string
example: "yes"
responses:
200:
description: OK
schema:
"$ref": "#/definitions/BroadcastTxCommitResult"
400:
description: Invalid proposal id or vote body
401:
description: Key password is wrong
500:
description: Internal Server Error
get:
summary: Query voters
description: Query voters information by proposalId
produces:
- application/json
tags:
- ICS22
parameters:
- type: string
description: proposal id
name: proposalId
required: true
in: path
responses:
200:
description: OK
schema:
type: array
items:
"$ref": "#/definitions/Vote"
400:
description: Invalid proposal id
500:
description: Internal Server Error
/gov/proposals/{proposalId}: /gov/proposals/{proposalId}:
get: get:
summary: Query a proposal summary: Query a proposal
@ -1436,11 +1280,76 @@ paths:
200: 200:
description: OK description: OK
schema: schema:
"$ref": "#/definitions/TextProposal" $ref: "#/definitions/TextProposal"
400: 400:
description: Invalid proposal id description: Invalid proposal id
500: 500:
description: Internal Server Error description: Internal Server Error
/gov/proposals/{proposalId}/deposits:
get:
summary: Query deposits
description: Query deposits by proposalId
produces:
- application/json
tags:
- ICS22
parameters:
- type: string
name: proposalId
required: true
in: path
responses:
200:
description: OK
schema:
type: array
items:
$ref: "#/definitions/Deposit"
400:
description: Invalid proposal id
500:
description: Internal Server Error
post:
summary: Deposit tokens to a proposal
description: Send transaction to deposit tokens to a proposal
consumes:
- application/json
produces:
- application/json
tags:
- ICS22
parameters:
- type: string
description: proposal id
name: proposalId
required: true
in: path
- description: ''
name: post_deposit_body
in: body
required: true
schema:
type: object
properties:
base_req:
$ref: "#/definitions/BaseReq"
depositor:
$ref: "#/definitions/Address"
amount:
type: array
items:
$ref: "#/definitions/Coin"
responses:
200:
description: OK
schema:
$ref: "#/definitions/BroadcastTxCommitResult"
400:
description: Invalid proposal id or deposit body
401:
description: Key password is wrong
500:
description: Internal Server Error
/gov/proposals/{proposalId}/deposits/{depositor}: /gov/proposals/{proposalId}/deposits/{depositor}:
get: get:
summary: Query deposit summary: Query deposit
@ -1471,6 +1380,71 @@ paths:
description: Found no deposit description: Found no deposit
500: 500:
description: Internal Server Error description: Internal Server Error
/gov/proposals/{proposalId}/votes:
get:
summary: Query voters
description: Query voters information by proposalId
produces:
- application/json
tags:
- ICS22
parameters:
- type: string
description: proposal id
name: proposalId
required: true
in: path
responses:
200:
description: OK
schema:
type: array
items:
$ref: "#/definitions/Vote"
400:
description: Invalid proposal id
500:
description: Internal Server Error
post:
summary: Vote a proposal
description: Send transaction to vote a proposal
consumes:
- application/json
produces:
- application/json
tags:
- ICS22
parameters:
- type: string
description: proposal id
name: proposalId
required: true
in: path
- description: valid value of `"option"` field can be `"yes"`, `"no"`, `"no_with_veto"` and `"abstain"`
name: post_vote_body
in: body
required: true
schema:
type: object
properties:
base_req:
$ref: "#/definitions/BaseReq"
voter:
$ref: "#/definitions/Address"
option:
type: string
example: "yes"
responses:
200:
description: OK
schema:
$ref: "#/definitions/BroadcastTxCommitResult"
400:
description: Invalid proposal id or vote body
401:
description: Key password is wrong
500:
description: Internal Server Error
/gov/proposals/{proposalId}/votes/{voter}: /gov/proposals/{proposalId}/votes/{voter}:
get: get:
summary: Query vote summary: Query vote
@ -1501,6 +1475,29 @@ paths:
description: Found no vote description: Found no vote
500: 500:
description: Internal Server Error description: Internal Server Error
/gov/proposals/{proposalId}/tally:
get:
summary: Get a proposal's tally result at the current time
description: Gets a proposal's tally result at the current time. If the proposal is pending deposits (i.e status 'DepositPeriod') it returns an empty tally result.
produces:
- application/json
tags:
- ICS22
parameters:
- type: string
description: proposal id
name: proposalId
required: true
in: path
responses:
200:
description: OK
schema:
$ref: "#/definitions/TallyResult"
400:
description: Invalid proposal id
500:
description: Internal Server Error
/gov/parameters/deposit: /gov/parameters/deposit:
get: get:
summary: Query governance deposit parameters summary: Query governance deposit parameters
@ -1598,7 +1595,7 @@ definitions:
tags: tags:
type: array type: array
items: items:
"$ref": "#/definitions/KVPair" $ref: "#/definitions/KVPair"
example: example:
code: 0 code: 0
data: data data: data
@ -1627,7 +1624,7 @@ definitions:
tags: tags:
type: array type: array
items: items:
"$ref": "#/definitions/KVPair" $ref: "#/definitions/KVPair"
example: example:
code: 5 code: 5
data: data data: data
@ -1888,6 +1885,12 @@ definitions:
gas_adjustment: gas_adjustment:
type: string type: string
example: "1.2" example: "1.2"
generate_only:
type: boolean
example: false
simulate:
type: boolean
example: true
TendermintValidator: TendermintValidator:
type: object type: object
properties: properties:
@ -1922,7 +1925,7 @@ definitions:
total_deposit: total_deposit:
type: array type: array
items: items:
"$ref": "#/definitions/Coin" $ref: "#/definitions/Coin"
voting_start_time: voting_start_time:
type: string type: string
Deposit: Deposit:
@ -1931,11 +1934,11 @@ definitions:
amount: amount:
type: array type: array
items: items:
"$ref": "#/definitions/Coin" $ref: "#/definitions/Coin"
proposal_id: proposal_id:
type: integer type: integer
depositor: depositor:
"$ref": "#/definitions/Address" $ref: "#/definitions/Address"
TallyResult: TallyResult:
type: object type: object
properties: properties:

View File

@ -14,9 +14,10 @@ import (
"strings" "strings"
"testing" "testing"
stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types"
"github.com/tendermint/tendermint/crypto/secp256k1" "github.com/tendermint/tendermint/crypto/secp256k1"
stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types"
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/keys" "github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/client/rpc" "github.com/cosmos/cosmos-sdk/client/rpc"
@ -33,7 +34,6 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
txbuilder "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
tmcfg "github.com/tendermint/tendermint/config" tmcfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
@ -48,6 +48,8 @@ import (
tmrpc "github.com/tendermint/tendermint/rpc/lib/server" tmrpc "github.com/tendermint/tendermint/rpc/lib/server"
tmtypes "github.com/tendermint/tendermint/types" tmtypes "github.com/tendermint/tendermint/types"
txbuilder "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
authRest "github.com/cosmos/cosmos-sdk/x/auth/client/rest" authRest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
bankRest "github.com/cosmos/cosmos-sdk/x/bank/client/rest" bankRest "github.com/cosmos/cosmos-sdk/x/bank/client/rest"
govRest "github.com/cosmos/cosmos-sdk/x/gov/client/rest" govRest "github.com/cosmos/cosmos-sdk/x/gov/client/rest"

View File

@ -8,11 +8,12 @@ import (
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/client/utils"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
tmliteProxy "github.com/tendermint/tendermint/lite/proxy" tmliteProxy "github.com/tendermint/tendermint/lite/proxy"
"github.com/cosmos/cosmos-sdk/client/utils"
) )
//BlockCommand returns the verified block data for a given heights //BlockCommand returns the verified block data for a given heights

View File

@ -5,9 +5,10 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
"github.com/spf13/viper"
) )
const ( const (

View File

@ -7,11 +7,12 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/client/utils" "github.com/cosmos/cosmos-sdk/client/utils"
"github.com/spf13/viper"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
) )
// StatusCommand returns the status of the network // StatusCommand returns the status of the network

View File

@ -9,12 +9,13 @@ import (
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper"
tmtypes "github.com/tendermint/tendermint/types"
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/client/utils" "github.com/cosmos/cosmos-sdk/client/utils"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/spf13/viper"
tmtypes "github.com/tendermint/tendermint/types"
) )
// TODO these next two functions feel kinda hacky based on their placement // TODO these next two functions feel kinda hacky based on their placement

View File

@ -3,10 +3,11 @@ package tx
import ( import (
"net/http" "net/http"
"io/ioutil"
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/client/utils" "github.com/cosmos/cosmos-sdk/client/utils"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
"io/ioutil"
) )
const ( const (

View File

@ -12,13 +12,14 @@ import (
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
"github.com/spf13/viper"
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/client/utils" "github.com/cosmos/cosmos-sdk/client/utils"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
"github.com/spf13/viper"
) )
// QueryTxCmd implements the default command for a tx query. // QueryTxCmd implements the default command for a tx query.

View File

@ -4,7 +4,6 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"net/url"
"strconv" "strconv"
"strings" "strings"
@ -17,11 +16,6 @@ import (
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder" authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
) )
const (
queryArgDryRun = "simulate"
queryArgGenerateOnly = "generate_only"
)
//---------------------------------------- //----------------------------------------
// Basic HTTP utilities // Basic HTTP utilities
@ -39,18 +33,6 @@ func WriteSimulationResponse(w http.ResponseWriter, gas uint64) {
w.Write([]byte(fmt.Sprintf(`{"gas_estimate":%v}`, gas))) w.Write([]byte(fmt.Sprintf(`{"gas_estimate":%v}`, gas)))
} }
// HasDryRunArg returns true if the request's URL query contains the dry run
// argument and its value is set to "true".
func HasDryRunArg(r *http.Request) bool {
return urlQueryHasArg(r.URL, queryArgDryRun)
}
// HasGenerateOnlyArg returns whether a URL's query "generate-only" parameter
// is set to "true".
func HasGenerateOnlyArg(r *http.Request) bool {
return urlQueryHasArg(r.URL, queryArgGenerateOnly)
}
// ParseInt64OrReturnBadRequest converts s to a int64 value. // ParseInt64OrReturnBadRequest converts s to a int64 value.
func ParseInt64OrReturnBadRequest(w http.ResponseWriter, s string) (n int64, ok bool) { func ParseInt64OrReturnBadRequest(w http.ResponseWriter, s string) (n int64, ok bool) {
var err error var err error
@ -113,8 +95,6 @@ func WriteGenerateStdTxResponse(w http.ResponseWriter, txBldr authtxb.TxBuilder,
return return
} }
func urlQueryHasArg(url *url.URL, arg string) bool { return url.Query().Get(arg) == "true" }
//---------------------------------------- //----------------------------------------
// Building / Sending utilities // Building / Sending utilities
@ -128,6 +108,8 @@ type BaseReq struct {
Sequence uint64 `json:"sequence"` Sequence uint64 `json:"sequence"`
Gas string `json:"gas"` Gas string `json:"gas"`
GasAdjustment string `json:"gas_adjustment"` GasAdjustment string `json:"gas_adjustment"`
GenerateOnly bool `json:"generate_only"`
Simulate bool `json:"simulate"`
} }
// Sanitize performs basic sanitization on a BaseReq object. // Sanitize performs basic sanitization on a BaseReq object.
@ -140,6 +122,8 @@ func (br BaseReq) Sanitize() BaseReq {
GasAdjustment: strings.TrimSpace(br.GasAdjustment), GasAdjustment: strings.TrimSpace(br.GasAdjustment),
AccountNumber: br.AccountNumber, AccountNumber: br.AccountNumber,
Sequence: br.Sequence, Sequence: br.Sequence,
GenerateOnly: br.GenerateOnly,
Simulate: br.Simulate,
} }
} }
@ -175,21 +159,21 @@ func ReadRESTReq(w http.ResponseWriter, r *http.Request, cdc *codec.Codec, req i
// ValidateBasic performs basic validation of a BaseReq. If custom validation // ValidateBasic performs basic validation of a BaseReq. If custom validation
// logic is needed, the implementing request handler should perform those // logic is needed, the implementing request handler should perform those
// checks manually. // checks manually.
func (br BaseReq) ValidateBasic(w http.ResponseWriter) bool { func (br BaseReq) ValidateBasic(w http.ResponseWriter, cliCtx context.CLIContext) bool {
switch { if !cliCtx.GenerateOnly && !cliCtx.Simulate {
case len(br.Name) == 0: switch {
case len(br.Password) == 0:
WriteErrorResponse(w, http.StatusUnauthorized, "password required but not specified")
return false
case len(br.ChainID) == 0:
WriteErrorResponse(w, http.StatusUnauthorized, "chain-id required but not specified")
return false
}
}
if len(br.Name) == 0 {
WriteErrorResponse(w, http.StatusUnauthorized, "name required but not specified") WriteErrorResponse(w, http.StatusUnauthorized, "name required but not specified")
return false return false
case len(br.Password) == 0:
WriteErrorResponse(w, http.StatusUnauthorized, "password required but not specified")
return false
case len(br.ChainID) == 0:
WriteErrorResponse(w, http.StatusUnauthorized, "chainID required but not specified")
return false
} }
return true return true
} }
@ -223,14 +207,14 @@ func CompleteAndBroadcastTxREST(w http.ResponseWriter, r *http.Request, cliCtx c
Sequence: baseReq.Sequence, Sequence: baseReq.Sequence,
} }
if HasDryRunArg(r) || txBldr.SimulateGas { if baseReq.Simulate || txBldr.SimulateGas {
newBldr, err := EnrichCtxWithGas(txBldr, cliCtx, baseReq.Name, msgs) newBldr, err := EnrichCtxWithGas(txBldr, cliCtx, baseReq.Name, msgs)
if err != nil { if err != nil {
WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return return
} }
if HasDryRunArg(r) { if baseReq.Simulate {
WriteSimulationResponse(w, newBldr.Gas) WriteSimulationResponse(w, newBldr.Gas)
return return
} }
@ -238,7 +222,7 @@ func CompleteAndBroadcastTxREST(w http.ResponseWriter, r *http.Request, cliCtx c
txBldr = newBldr txBldr = newBldr
} }
if HasGenerateOnlyArg(r) { if baseReq.GenerateOnly {
WriteGenerateStdTxResponse(w, txBldr, msgs) WriteGenerateStdTxResponse(w, txBldr, msgs)
return return
} }

View File

@ -6,13 +6,14 @@ import (
"io" "io"
"os" "os"
"github.com/tendermint/go-amino"
"github.com/tendermint/tendermint/libs/common"
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/client/keys" "github.com/cosmos/cosmos-sdk/client/keys"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder" authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
"github.com/tendermint/go-amino"
"github.com/tendermint/tendermint/libs/common"
) )
// CompleteAndBroadcastTxCli implements a utility function that facilitates // CompleteAndBroadcastTxCli implements a utility function that facilitates
@ -33,14 +34,14 @@ func CompleteAndBroadcastTxCli(txBldr authtxb.TxBuilder, cliCtx context.CLIConte
return err return err
} }
if txBldr.SimulateGas || cliCtx.DryRun { if txBldr.SimulateGas || cliCtx.Simulate {
txBldr, err = EnrichCtxWithGas(txBldr, cliCtx, name, msgs) txBldr, err = EnrichCtxWithGas(txBldr, cliCtx, name, msgs)
if err != nil { if err != nil {
return err return err
} }
fmt.Fprintf(os.Stderr, "estimated gas = %v\n", txBldr.Gas) fmt.Fprintf(os.Stderr, "estimated gas = %v\n", txBldr.Gas)
} }
if cliCtx.DryRun { if cliCtx.Simulate {
return nil return nil
} }

View File

@ -4,10 +4,11 @@ import (
"errors" "errors"
"testing" "testing"
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/tendermint/tendermint/libs/common" "github.com/tendermint/tendermint/libs/common"
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
sdk "github.com/cosmos/cosmos-sdk/types"
) )
func TestParseQueryResponse(t *testing.T) { func TestParseQueryResponse(t *testing.T) {

View File

@ -9,9 +9,10 @@ import (
"path/filepath" "path/filepath"
"github.com/cosmos/cosmos-sdk/version"
"github.com/spf13/cobra" "github.com/spf13/cobra"
tmversion "github.com/tendermint/tendermint/version" tmversion "github.com/tendermint/tendermint/version"
"github.com/cosmos/cosmos-sdk/version"
) )
var remoteBasecoinPath = "github.com/cosmos/cosmos-sdk/docs/examples/basecoin" var remoteBasecoinPath = "github.com/cosmos/cosmos-sdk/docs/examples/basecoin"

View File

@ -6,6 +6,11 @@ import (
"os" "os"
"sort" "sort"
abci "github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
bam "github.com/cosmos/cosmos-sdk/baseapp" bam "github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
@ -17,10 +22,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/params" "github.com/cosmos/cosmos-sdk/x/params"
"github.com/cosmos/cosmos-sdk/x/slashing" "github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/stake" "github.com/cosmos/cosmos-sdk/x/stake"
abci "github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
) )
const ( const (

View File

@ -4,6 +4,10 @@ import (
"os" "os"
"testing" "testing"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
distr "github.com/cosmos/cosmos-sdk/x/distribution" distr "github.com/cosmos/cosmos-sdk/x/distribution"
@ -11,9 +15,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/mint" "github.com/cosmos/cosmos-sdk/x/mint"
"github.com/cosmos/cosmos-sdk/x/slashing" "github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/stake" "github.com/cosmos/cosmos-sdk/x/stake"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
) )

View File

@ -3,11 +3,12 @@ package app
import ( import (
"fmt" "fmt"
"github.com/tendermint/tendermint/crypto/secp256k1"
"github.com/cosmos/cosmos-sdk/cmd/gaia/app" "github.com/cosmos/cosmos-sdk/cmd/gaia/app"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/bank"
"github.com/tendermint/tendermint/crypto/secp256k1"
) )
// This will fail half the time with the second output being 173 // This will fail half the time with the second output being 173

View File

@ -4,6 +4,9 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
abci "github.com/tendermint/tendermint/abci/types"
tmtypes "github.com/tendermint/tendermint/types"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
@ -12,8 +15,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/mint" "github.com/cosmos/cosmos-sdk/x/mint"
"github.com/cosmos/cosmos-sdk/x/slashing" "github.com/cosmos/cosmos-sdk/x/slashing"
stake "github.com/cosmos/cosmos-sdk/x/stake" stake "github.com/cosmos/cosmos-sdk/x/stake"
abci "github.com/tendermint/tendermint/abci/types"
tmtypes "github.com/tendermint/tendermint/types"
) )
// export the state of gaia for a genesis file // export the state of gaia for a genesis file
@ -123,7 +124,6 @@ func (app *GaiaApp) prepForZeroHeightGenesis(ctx sdk.Context) {
panic("expected validator, not found") panic("expected validator, not found")
} }
validator.BondHeight = 0 validator.BondHeight = 0
validator.BondIntraTxCounter = counter
validator.UnbondingHeight = 0 validator.UnbondingHeight = 0
app.stakeKeeper.SetValidator(ctx, validator) app.stakeKeeper.SetValidator(ctx, validator)
counter++ counter++

View File

@ -10,6 +10,8 @@ import (
"sort" "sort"
"strings" "strings"
tmtypes "github.com/tendermint/tendermint/types"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
@ -19,7 +21,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/slashing" "github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/stake" "github.com/cosmos/cosmos-sdk/x/stake"
stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types"
tmtypes "github.com/tendermint/tendermint/types"
) )
var ( var (

View File

@ -7,13 +7,14 @@ import (
"github.com/tendermint/tendermint/crypto/secp256k1" "github.com/tendermint/tendermint/crypto/secp256k1"
tmtypes "github.com/tendermint/tendermint/types" tmtypes "github.com/tendermint/tendermint/types"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/stake" "github.com/cosmos/cosmos-sdk/x/stake"
stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
) )
var ( var (

View File

@ -4,12 +4,13 @@ import (
"fmt" "fmt"
"time" "time"
abci "github.com/tendermint/tendermint/abci/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
banksim "github.com/cosmos/cosmos-sdk/x/bank/simulation" banksim "github.com/cosmos/cosmos-sdk/x/bank/simulation"
distrsim "github.com/cosmos/cosmos-sdk/x/distribution/simulation" distrsim "github.com/cosmos/cosmos-sdk/x/distribution/simulation"
"github.com/cosmos/cosmos-sdk/x/mock/simulation" "github.com/cosmos/cosmos-sdk/x/mock/simulation"
stakesim "github.com/cosmos/cosmos-sdk/x/stake/simulation" stakesim "github.com/cosmos/cosmos-sdk/x/stake/simulation"
abci "github.com/tendermint/tendermint/abci/types"
) )
func (app *GaiaApp) runtimeInvariants() []simulation.Invariant { func (app *GaiaApp) runtimeInvariants() []simulation.Invariant {

View File

@ -50,7 +50,7 @@ func init() {
flag.BoolVar(&enabled, "SimulationEnabled", false, "Enable the simulation") flag.BoolVar(&enabled, "SimulationEnabled", false, "Enable the simulation")
flag.BoolVar(&verbose, "SimulationVerbose", false, "Verbose log output") flag.BoolVar(&verbose, "SimulationVerbose", false, "Verbose log output")
flag.BoolVar(&commit, "SimulationCommit", false, "Have the simulation commit") flag.BoolVar(&commit, "SimulationCommit", false, "Have the simulation commit")
flag.IntVar(&period, "SimulationPeriod", 100, "Run slow invariants only once every period assertions") flag.IntVar(&period, "SimulationPeriod", 1, "Run slow invariants only once every period assertions")
} }
func appStateFn(r *rand.Rand, accs []simulation.Account) json.RawMessage { func appStateFn(r *rand.Rand, accs []simulation.Account) json.RawMessage {

View File

@ -645,6 +645,37 @@ trust_node = true
cleanupDirs(gaiadHome, gaiacliHome) cleanupDirs(gaiadHome, gaiacliHome)
} }
func TestGaiadCollectGentxs(t *testing.T) {
t.Parallel()
// Initialise temporary directories
gaiadHome, gaiacliHome := getTestingHomeDirs(t.Name())
gentxDir, err := ioutil.TempDir("", "")
gentxDoc := filepath.Join(gentxDir, "gentx.json")
require.NoError(t, err)
tests.ExecuteT(t, fmt.Sprintf("gaiad --home=%s unsafe-reset-all", gaiadHome), "")
os.RemoveAll(filepath.Join(gaiadHome, "config", "gentx"))
executeWrite(t, fmt.Sprintf("gaiacli keys delete --home=%s foo", gaiacliHome), app.DefaultKeyPass)
executeWrite(t, fmt.Sprintf("gaiacli keys delete --home=%s bar", gaiacliHome), app.DefaultKeyPass)
executeWriteCheckErr(t, fmt.Sprintf("gaiacli keys add --home=%s foo", gaiacliHome), app.DefaultKeyPass)
executeWriteCheckErr(t, fmt.Sprintf("gaiacli keys add --home=%s bar", gaiacliHome), app.DefaultKeyPass)
executeWriteCheckErr(t, fmt.Sprintf("gaiacli config --home=%s output json", gaiacliHome))
fooAddr, _ := executeGetAddrPK(t, fmt.Sprintf("gaiacli keys show foo --home=%s", gaiacliHome))
// Run init
_ = executeInit(t, fmt.Sprintf("gaiad init -o --moniker=foo --home=%s", gaiadHome))
// Add account to genesis.json
executeWriteCheckErr(t, fmt.Sprintf(
"gaiad add-genesis-account %s 150%s,1000fooToken --home=%s", fooAddr, stakeTypes.DefaultBondDenom, gaiadHome))
executeWrite(t, fmt.Sprintf("cat %s%sconfig%sgenesis.json", gaiadHome, string(os.PathSeparator), string(os.PathSeparator)))
// Write gentx file
executeWriteCheckErr(t, fmt.Sprintf(
"gaiad gentx --name=foo --home=%s --home-client=%s --output-document=%s", gaiadHome, gaiacliHome, gentxDoc), app.DefaultKeyPass)
// Collect gentxs from a custom directory
executeWriteCheckErr(t, fmt.Sprintf("gaiad collect-gentxs --home=%s --gentx-dir=%s", gaiadHome, gentxDir), app.DefaultKeyPass)
cleanupDirs(gaiadHome, gaiacliHome, gentxDir)
}
//___________________________________________________________________________________ //___________________________________________________________________________________
// helper methods // helper methods

View File

@ -10,12 +10,13 @@ import (
"strconv" "strconv"
"strings" "strings"
gaia "github.com/cosmos/cosmos-sdk/cmd/gaia/app"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/crypto/ed25519"
gaia "github.com/cosmos/cosmos-sdk/cmd/gaia/app"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
) )
func init() { func init() {

View File

@ -0,0 +1,51 @@
package main
import (
"encoding/hex"
"fmt"
"os"
"github.com/tendermint/tendermint/libs/bech32"
)
var bech32Prefixes = []string{"cosmos", "cosmospub", "cosmosvaloper", "cosmosvaloperpub", "cosmosvalcons", "cosmosvalconspub"}
func main() {
if len(os.Args) < 2 {
fmt.Println("Must specify an input string")
}
arg := os.Args[1]
runFromBech32(arg)
runFromHex(arg)
}
// Print info from bech32.
func runFromBech32(bech32str string) {
hrp, bz, err := bech32.DecodeAndConvert(bech32str)
if err != nil {
fmt.Println("Not a valid bech32 string")
return
}
fmt.Println("Bech32 parse:")
fmt.Printf("Human readible part: %v\nBytes (hex): %X\n",
hrp,
bz,
)
}
func runFromHex(hexaddr string) {
bz, err := hex.DecodeString(hexaddr)
if err != nil {
fmt.Println("Not a valid hex string")
return
}
fmt.Println("Hex parse:")
fmt.Println("Bech32 formats:")
for _, prefix := range bech32Prefixes {
bech32Addr, err := bech32.ConvertAndEncode(prefix, bz)
if err != nil {
panic(err)
}
fmt.Println(" - " + bech32Addr)
}
}

View File

@ -131,7 +131,7 @@ func run(rootDir string) {
_ = proxyApp.Stop() _ = proxyApp.Stop()
}() }()
var state tmsm.State = tmsm.LoadState(tmDB) state := tmsm.LoadState(tmDB)
if state.LastBlockHeight == 0 { if state.LastBlockHeight == 0 {
// Send InitChain msg // Send InitChain msg
fmt.Println("Sending InitChain msg") fmt.Println("Sending InitChain msg")

View File

@ -4,17 +4,22 @@ import (
"encoding/json" "encoding/json"
"path/filepath" "path/filepath"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
cfg "github.com/tendermint/tendermint/config" cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/libs/cli" "github.com/tendermint/tendermint/libs/cli"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/x/auth"
)
const (
flagGenTxDir = "gentx-dir"
) )
type initConfig struct { type initConfig struct {
@ -34,7 +39,6 @@ func CollectGenTxsCmd(ctx *server.Context, cdc *codec.Codec) *cobra.Command {
config := ctx.Config config := ctx.Config
config.SetRoot(viper.GetString(cli.HomeFlag)) config.SetRoot(viper.GetString(cli.HomeFlag))
name := viper.GetString(client.FlagName) name := viper.GetString(client.FlagName)
nodeID, valPubKey, err := InitializeNodeValidatorFiles(config) nodeID, valPubKey, err := InitializeNodeValidatorFiles(config)
if err != nil { if err != nil {
return err return err
@ -45,19 +49,13 @@ func CollectGenTxsCmd(ctx *server.Context, cdc *codec.Codec) *cobra.Command {
return err return err
} }
toPrint := printInfo{ genTxsDir := viper.GetString(flagGenTxDir)
Moniker: config.Moniker, if genTxsDir == "" {
ChainID: genDoc.ChainID, genTxsDir = filepath.Join(config.RootDir, "config", "gentx")
NodeID: nodeID,
} }
initCfg := initConfig{ toPrint := newPrintInfo(config.Moniker, genDoc.ChainID, nodeID, genTxsDir, json.RawMessage(""))
ChainID: genDoc.ChainID, initCfg := newInitConfig(genDoc.ChainID, genTxsDir, name, nodeID, valPubKey)
GenTxsDir: filepath.Join(config.RootDir, "config", "gentx"),
Name: name,
NodeID: nodeID,
ValPubKey: valPubKey,
}
appMessage, err := genAppStateFromConfig(cdc, config, initCfg, genDoc) appMessage, err := genAppStateFromConfig(cdc, config, initCfg, genDoc)
if err != nil { if err != nil {
@ -72,6 +70,9 @@ func CollectGenTxsCmd(ctx *server.Context, cdc *codec.Codec) *cobra.Command {
} }
cmd.Flags().String(cli.HomeFlag, app.DefaultNodeHome, "node's home directory") cmd.Flags().String(cli.HomeFlag, app.DefaultNodeHome, "node's home directory")
cmd.Flags().String(flagGenTxDir, "",
"override default \"gentx\" directory from which collect and execute "+
"genesis transactions; default [--home]/config/gentx/")
return cmd return cmd
} }
@ -116,3 +117,27 @@ func genAppStateFromConfig(
err = ExportGenesisFile(genFile, initCfg.ChainID, nil, appState) err = ExportGenesisFile(genFile, initCfg.ChainID, nil, appState)
return return
} }
func newInitConfig(chainID, genTxsDir, name, nodeID string,
valPubKey crypto.PubKey) initConfig {
return initConfig{
ChainID: chainID,
GenTxsDir: genTxsDir,
Name: name,
NodeID: nodeID,
ValPubKey: valPubKey,
}
}
func newPrintInfo(moniker, chainID, nodeID, genTxsDir string,
appMessage json.RawMessage) printInfo {
return printInfo{
Moniker: moniker,
ChainID: chainID,
NodeID: nodeID,
GenTxsDir: genTxsDir,
AppMessage: appMessage,
}
}

View File

@ -4,15 +4,16 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/tendermint/tendermint/libs/cli"
"github.com/tendermint/tendermint/libs/common"
"github.com/cosmos/cosmos-sdk/cmd/gaia/app" "github.com/cosmos/cosmos-sdk/cmd/gaia/app"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/tendermint/tendermint/libs/cli"
"github.com/tendermint/tendermint/libs/common"
) )
// AddGenesisAccountCmd returns add-genesis-account cobra Command // AddGenesisAccountCmd returns add-genesis-account cobra Command

View File

@ -1,9 +1,10 @@
package init package init
import ( import (
"testing"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto/secp256k1" "github.com/tendermint/tendermint/crypto/secp256k1"
"testing"
"github.com/cosmos/cosmos-sdk/cmd/gaia/app" "github.com/cosmos/cosmos-sdk/cmd/gaia/app"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"

View File

@ -11,6 +11,11 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/crypto"
tmcli "github.com/tendermint/tendermint/libs/cli"
"github.com/tendermint/tendermint/libs/common"
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/client/keys" "github.com/cosmos/cosmos-sdk/client/keys"
@ -23,10 +28,6 @@ import (
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder" authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
"github.com/cosmos/cosmos-sdk/x/stake/client/cli" "github.com/cosmos/cosmos-sdk/x/stake/client/cli"
stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types"
cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/crypto"
tmcli "github.com/tendermint/tendermint/libs/cli"
"github.com/tendermint/tendermint/libs/common"
) )
const ( const (
@ -136,9 +137,12 @@ following delegation and commission default parameters:
} }
// Fetch output file name // Fetch output file name
outputDocument, err := makeOutputFilepath(config.RootDir, nodeID) outputDocument := viper.GetString(client.FlagOutputDocument)
if err != nil { if outputDocument == "" {
return err outputDocument, err = makeOutputFilepath(config.RootDir, nodeID)
if err != nil {
return err
}
} }
if err := writeSignedGenTx(cdc, outputDocument, signedTx); err != nil { if err := writeSignedGenTx(cdc, outputDocument, signedTx); err != nil {
@ -153,6 +157,8 @@ following delegation and commission default parameters:
cmd.Flags().String(tmcli.HomeFlag, app.DefaultNodeHome, "node's home directory") cmd.Flags().String(tmcli.HomeFlag, app.DefaultNodeHome, "node's home directory")
cmd.Flags().String(flagClientHome, app.DefaultCLIHome, "client's home directory") cmd.Flags().String(flagClientHome, app.DefaultCLIHome, "client's home directory")
cmd.Flags().String(client.FlagName, "", "name of private key with which to sign the gentx") cmd.Flags().String(client.FlagName, "", "name of private key with which to sign the gentx")
cmd.Flags().String(client.FlagOutputDocument, "",
"write the genesis transaction JSON document to the given file instead of the default location")
cmd.Flags().AddFlagSet(cli.FsCommissionCreate) cmd.Flags().AddFlagSet(cli.FsCommissionCreate)
cmd.Flags().AddFlagSet(cli.FsAmount) cmd.Flags().AddFlagSet(cli.FsAmount)
cmd.Flags().AddFlagSet(cli.FsPk) cmd.Flags().AddFlagSet(cli.FsPk)

View File

@ -6,15 +6,16 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/server"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
cfg "github.com/tendermint/tendermint/config" cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/libs/cli" "github.com/tendermint/tendermint/libs/cli"
"github.com/tendermint/tendermint/libs/common" "github.com/tendermint/tendermint/libs/common"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/server"
) )
const ( const (
@ -27,6 +28,7 @@ type printInfo struct {
Moniker string `json:"moniker"` Moniker string `json:"moniker"`
ChainID string `json:"chain_id"` ChainID string `json:"chain_id"`
NodeID string `json:"node_id"` NodeID string `json:"node_id"`
GenTxsDir string `json:"gentxs_dir"`
AppMessage json.RawMessage `json:"app_message"` AppMessage json.RawMessage `json:"app_message"`
} }
@ -76,12 +78,7 @@ func InitCmd(ctx *server.Context, cdc *codec.Codec) *cobra.Command {
return err return err
} }
toPrint := printInfo{ toPrint := newPrintInfo(config.Moniker, chainID, nodeID, "", appState)
ChainID: chainID,
Moniker: config.Moniker,
NodeID: nodeID,
AppMessage: appState,
}
cfg.WriteConfigFile(filepath.Join(config.RootDir, "config", "config.toml"), config) cfg.WriteConfigFile(filepath.Join(config.RootDir, "config", "config.toml"), config)

View File

@ -8,17 +8,19 @@ import (
"testing" "testing"
"time" "time"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
"github.com/tendermint/tendermint/libs/cli" "github.com/tendermint/tendermint/libs/cli"
"github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/server/mock" "github.com/cosmos/cosmos-sdk/cmd/gaia/app"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
abciServer "github.com/tendermint/tendermint/abci/server" abciServer "github.com/tendermint/tendermint/abci/server"
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands" tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/server/mock"
"github.com/spf13/viper" "github.com/spf13/viper"
) )

View File

@ -16,7 +16,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/stake" "github.com/cosmos/cosmos-sdk/x/stake"
stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types"
"github.com/cosmos/cosmos-sdk/server"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
cfg "github.com/tendermint/tendermint/config" cfg "github.com/tendermint/tendermint/config"
@ -24,6 +23,8 @@ import (
cmn "github.com/tendermint/tendermint/libs/common" cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
tmtime "github.com/tendermint/tendermint/types/time" tmtime "github.com/tendermint/tendermint/types/time"
"github.com/cosmos/cosmos-sdk/server"
) )
var ( var (
@ -278,13 +279,7 @@ func collectGenFiles(
config.SetRoot(nodeDir) config.SetRoot(nodeDir)
nodeID, valPubKey := nodeIDs[i], valPubKeys[i] nodeID, valPubKey := nodeIDs[i], valPubKeys[i]
initCfg := initConfig{ initCfg := newInitConfig(chainID, gentxsDir, moniker, nodeID, valPubKey)
ChainID: chainID,
GenTxsDir: gentxsDir,
Name: moniker,
NodeID: nodeID,
ValPubKey: valPubKey,
}
genDoc, err := loadGenesisDoc(cdc, config.GenesisFile()) genDoc, err := loadGenesisDoc(cdc, config.GenesisFile())
if err != nil { if err != nil {

View File

@ -6,8 +6,6 @@ import (
"io/ioutil" "io/ioutil"
"time" "time"
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
"github.com/cosmos/cosmos-sdk/codec"
amino "github.com/tendermint/go-amino" amino "github.com/tendermint/go-amino"
cfg "github.com/tendermint/tendermint/config" cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
@ -15,6 +13,9 @@ import (
"github.com/tendermint/tendermint/p2p" "github.com/tendermint/tendermint/p2p"
"github.com/tendermint/tendermint/privval" "github.com/tendermint/tendermint/privval"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
"github.com/cosmos/cosmos-sdk/codec"
) )
// ExportGenesisFile creates and writes the genesis configuration to disk. An // ExportGenesisFile creates and writes the genesis configuration to disk. An

View File

@ -1,9 +1,10 @@
package keys package keys
import ( import (
ccrypto "github.com/cosmos/cosmos-sdk/crypto"
amino "github.com/tendermint/go-amino" amino "github.com/tendermint/go-amino"
"github.com/tendermint/tendermint/crypto/encoding/amino" "github.com/tendermint/tendermint/crypto/encoding/amino"
ccrypto "github.com/cosmos/cosmos-sdk/crypto"
) )
var cdc = amino.NewCodec() var cdc = amino.NewCodec()

View File

@ -15,11 +15,12 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keys/mintkey" "github.com/cosmos/cosmos-sdk/crypto/keys/mintkey"
"github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/keyerror"
tmcrypto "github.com/tendermint/tendermint/crypto" tmcrypto "github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/encoding/amino" "github.com/tendermint/tendermint/crypto/encoding/amino"
"github.com/tendermint/tendermint/crypto/secp256k1" "github.com/tendermint/tendermint/crypto/secp256k1"
dbm "github.com/tendermint/tendermint/libs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/cosmos/cosmos-sdk/crypto/keys/keyerror"
) )
var _ Keybase = dbKeybase{} var _ Keybase = dbKeybase{}

View File

@ -13,8 +13,9 @@ import (
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/crypto/ed25519"
"github.com/cosmos/cosmos-sdk/types"
dbm "github.com/tendermint/tendermint/libs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/cosmos/cosmos-sdk/types"
) )
func init() { func init() {

View File

@ -11,8 +11,9 @@ import (
"github.com/tendermint/tendermint/crypto/encoding/amino" "github.com/tendermint/tendermint/crypto/encoding/amino"
"github.com/tendermint/tendermint/crypto/xsalsa20symmetric" "github.com/tendermint/tendermint/crypto/xsalsa20symmetric"
"github.com/cosmos/cosmos-sdk/crypto/keys/keyerror"
cmn "github.com/tendermint/tendermint/libs/common" cmn "github.com/tendermint/tendermint/libs/common"
"github.com/cosmos/cosmos-sdk/crypto/keys/keyerror"
) )
const ( const (

View File

@ -1,9 +1,10 @@
package keys package keys
import ( import (
ccrypto "github.com/cosmos/cosmos-sdk/crypto"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
ccrypto "github.com/cosmos/cosmos-sdk/crypto"
"github.com/cosmos/cosmos-sdk/crypto/keys/hd" "github.com/cosmos/cosmos-sdk/crypto/keys/hd"
"github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types"
) )

View File

@ -3,9 +3,10 @@ package app
import ( import (
"testing" "testing"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/crypto/ed25519"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -4,6 +4,12 @@ import (
"encoding/json" "encoding/json"
"os" "os"
abci "github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
tmtypes "github.com/tendermint/tendermint/types"
bam "github.com/cosmos/cosmos-sdk/baseapp" bam "github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/docs/examples/basecoin/types" "github.com/cosmos/cosmos-sdk/docs/examples/basecoin/types"
@ -11,11 +17,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosmos/cosmos-sdk/x/ibc" "github.com/cosmos/cosmos-sdk/x/ibc"
abci "github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
tmtypes "github.com/tendermint/tendermint/types"
) )
const ( const (

View File

@ -4,15 +4,16 @@ import (
"os" "os"
"testing" "testing"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/docs/examples/basecoin/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/crypto/ed25519"
dbm "github.com/tendermint/tendermint/libs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/docs/examples/basecoin/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
) )
func setGenesis(baseApp *BasecoinApp, accounts ...*types.AppAccount) (types.GenesisState, error) { func setGenesis(baseApp *BasecoinApp, accounts ...*types.AppAccount) (types.GenesisState, error) {

View File

@ -6,10 +6,11 @@ import (
"os" "os"
"testing" "testing"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/cmd/gaia/app" "github.com/cosmos/cosmos-sdk/cmd/gaia/app"
"github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/tests" "github.com/cosmos/cosmos-sdk/tests"
"github.com/stretchr/testify/require"
) )
var ( var (

View File

@ -9,6 +9,9 @@ import (
"github.com/cosmos/cosmos-sdk/client/tx" "github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/docs/examples/basecoin/app" "github.com/cosmos/cosmos-sdk/docs/examples/basecoin/app"
"github.com/spf13/cobra"
"github.com/tendermint/tendermint/libs/cli"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/version"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
@ -20,8 +23,6 @@ import (
slashing "github.com/cosmos/cosmos-sdk/x/slashing/client/rest" slashing "github.com/cosmos/cosmos-sdk/x/slashing/client/rest"
stakecmd "github.com/cosmos/cosmos-sdk/x/stake/client/cli" stakecmd "github.com/cosmos/cosmos-sdk/x/stake/client/cli"
stake "github.com/cosmos/cosmos-sdk/x/stake/client/rest" stake "github.com/cosmos/cosmos-sdk/x/stake/client/rest"
"github.com/spf13/cobra"
"github.com/tendermint/tendermint/libs/cli"
) )
const ( const (

View File

@ -11,10 +11,6 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/baseapp"
gaiaInit "github.com/cosmos/cosmos-sdk/cmd/gaia/init" gaiaInit "github.com/cosmos/cosmos-sdk/cmd/gaia/init"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/docs/examples/basecoin/app"
"github.com/cosmos/cosmos-sdk/server"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
@ -23,6 +19,11 @@ import (
dbm "github.com/tendermint/tendermint/libs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
tmtypes "github.com/tendermint/tendermint/types" tmtypes "github.com/tendermint/tendermint/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/docs/examples/basecoin/app"
"github.com/cosmos/cosmos-sdk/server"
) )
const ( const (

View File

@ -4,16 +4,17 @@ import (
"os" "os"
"testing" "testing"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/docs/examples/democoin/types"
"github.com/cosmos/cosmos-sdk/docs/examples/democoin/x/cool"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/crypto/ed25519"
dbm "github.com/tendermint/tendermint/libs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/docs/examples/democoin/types"
"github.com/cosmos/cosmos-sdk/docs/examples/democoin/x/cool"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
) )
func setGenesis(bapp *DemocoinApp, trend string, accs ...auth.BaseAccount) error { func setGenesis(bapp *DemocoinApp, trend string, accs ...auth.BaseAccount) error {

View File

@ -8,9 +8,10 @@ import (
"github.com/cosmos/cosmos-sdk/cmd/gaia/app" "github.com/cosmos/cosmos-sdk/cmd/gaia/app"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/tests" "github.com/cosmos/cosmos-sdk/tests"
"github.com/stretchr/testify/require"
) )
var ( var (

View File

@ -6,11 +6,12 @@ import (
"io" "io"
"os" "os"
"github.com/cosmos/cosmos-sdk/client"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/tendermint/tendermint/libs/common" "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/p2p" "github.com/tendermint/tendermint/p2p"
"github.com/cosmos/cosmos-sdk/client"
"github.com/spf13/cobra" "github.com/spf13/cobra"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"

View File

@ -3,8 +3,9 @@ package mock
import ( import (
"bytes" "bytes"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
sdk "github.com/cosmos/cosmos-sdk/types"
) )
// Validator implements sdk.Validator // Validator implements sdk.Validator

View File

@ -3,13 +3,14 @@ package cool
import ( import (
"testing" "testing"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto/ed25519"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
bank "github.com/cosmos/cosmos-sdk/x/bank" bank "github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosmos/cosmos-sdk/x/mock" "github.com/cosmos/cosmos-sdk/x/mock"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto/ed25519"
) )
var ( var (

View File

@ -5,8 +5,9 @@ import (
"math" "math"
"strconv" "strconv"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
sdk "github.com/cosmos/cosmos-sdk/types"
) )
// generate the mine message // generate the mine message

View File

@ -111,10 +111,6 @@ option that casts a `NoWithVeto` vote.*
Quorum is defined as the minimum percentage of voting power that needs to be Quorum is defined as the minimum percentage of voting power that needs to be
casted on a proposal for the result to be valid. casted on a proposal for the result to be valid.
In the initial version of the governance module, there will be no quorum
enforced by the protocol. Participation is ensured via the combination of
inheritance and validator's punishment for non-voting.
### Threshold ### Threshold
Threshold is defined as the minimum proportion of `Yes` votes (excluding Threshold is defined as the minimum proportion of `Yes` votes (excluding

View File

@ -24,6 +24,7 @@ type VotingParams struct {
```go ```go
type TallyParams struct { type TallyParams struct {
Quorum sdk.Dec // Minimum percentage of stake that needs to vote for a proposal to be considered valid
Threshold sdk.Dec // Minimum proportion of Yes votes for proposal to pass. Initial value: 0.5 Threshold sdk.Dec // Minimum proportion of Yes votes for proposal to pass. Initial value: 0.5
Veto sdk.Dec // Minimum proportion of Veto votes to Total votes ratio for proposal to be vetoed. Initial value: 1/3 Veto sdk.Dec // Minimum proportion of Veto votes to Total votes ratio for proposal to be vetoed. Initial value: 1/3
GovernancePenalty sdk.Dec // Penalty if validator does not vote GovernancePenalty sdk.Dec // Penalty if validator does not vote

View File

@ -22,7 +22,7 @@ sim() {
file="$tmpdir/gaia-simulation-seed-$seed-date-$(date -u +"%Y-%m-%dT%H:%M:%S+00:00").stdout" file="$tmpdir/gaia-simulation-seed-$seed-date-$(date -u +"%Y-%m-%dT%H:%M:%S+00:00").stdout"
echo "Writing stdout to $file..." echo "Writing stdout to $file..."
go test ./cmd/gaia/app -run $testname -SimulationEnabled=true -SimulationNumBlocks=$blocks \ go test ./cmd/gaia/app -run $testname -SimulationEnabled=true -SimulationNumBlocks=$blocks \
-SimulationVerbose=true -SimulationCommit=true -SimulationSeed=$seed -v -timeout 24h > $file -SimulationVerbose=true -SimulationCommit=true -SimulationSeed=$seed -SimulationPeriod=5 -v -timeout 24h > $file
} }
i=0 i=0

View File

@ -3,8 +3,9 @@ package config
import ( import (
"testing" "testing"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
) )
func TestDefaultConfig(t *testing.T) { func TestDefaultConfig(t *testing.T) {

View File

@ -7,10 +7,12 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/cosmos/cosmos-sdk/codec"
tmtypes "github.com/tendermint/tendermint/types"
"io/ioutil" "io/ioutil"
"path" "path"
tmtypes "github.com/tendermint/tendermint/types"
"github.com/cosmos/cosmos-sdk/codec"
) )
const ( const (

View File

@ -4,15 +4,18 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"github.com/cosmos/cosmos-sdk/crypto/keys"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
dbm "github.com/tendermint/tendermint/libs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
"github.com/cosmos/cosmos-sdk/crypto/keys"
tmtypes "github.com/tendermint/tendermint/types"
clkeys "github.com/cosmos/cosmos-sdk/client/keys" clkeys "github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
tmtypes "github.com/tendermint/tendermint/types"
) )
// SimpleGenTx is a simple genesis tx // SimpleGenTx is a simple genesis tx

View File

@ -3,9 +3,10 @@ package mock
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/tendermint/tendermint/types"
"path/filepath" "path/filepath"
"github.com/tendermint/tendermint/types"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
dbm "github.com/tendermint/tendermint/libs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"

View File

@ -1,9 +1,10 @@
package mock package mock
import ( import (
"github.com/tendermint/tendermint/types"
"testing" "testing"
"github.com/tendermint/tendermint/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"

View File

@ -2,12 +2,13 @@ package server
import ( import (
"fmt" "fmt"
"github.com/cosmos/cosmos-sdk/client"
"io/ioutil" "io/ioutil"
"net" "net"
"os" "os"
"testing" "testing"
"github.com/cosmos/cosmos-sdk/client"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/cli" "github.com/tendermint/tendermint/libs/cli"

View File

@ -3,15 +3,17 @@ package server
import ( import (
"fmt" "fmt"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands" tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
"github.com/tendermint/tendermint/p2p" "github.com/tendermint/tendermint/p2p"
pvm "github.com/tendermint/tendermint/privval" pvm "github.com/tendermint/tendermint/privval"
"github.com/cosmos/cosmos-sdk/client"
sdk "github.com/cosmos/cosmos-sdk/types"
) )
// ShowNodeIDCmd - ported from Tendermint, dump node ID to stdout // ShowNodeIDCmd - ported from Tendermint, dump node ID to stdout

View File

@ -13,15 +13,16 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/server/config"
"github.com/cosmos/cosmos-sdk/version"
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands" tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
cfg "github.com/tendermint/tendermint/config" cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/libs/cli" "github.com/tendermint/tendermint/libs/cli"
tmflags "github.com/tendermint/tendermint/libs/cli/flags" tmflags "github.com/tendermint/tendermint/libs/cli/flags"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/server/config"
"github.com/cosmos/cosmos-sdk/version"
) )
// server context // server context

View File

@ -4,8 +4,9 @@ import (
"encoding/json" "encoding/json"
"testing" "testing"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/codec"
) )
func TestInsertKeyJSON(t *testing.T) { func TestInsertKeyJSON(t *testing.T) {

View File

@ -3,8 +3,9 @@ package store
import ( import (
"io" "io"
sdk "github.com/cosmos/cosmos-sdk/types"
dbm "github.com/tendermint/tendermint/libs/db" dbm "github.com/tendermint/tendermint/libs/db"
sdk "github.com/cosmos/cosmos-sdk/types"
) )
// Wrapper type for dbm.Db with implementation of KVStore // Wrapper type for dbm.Db with implementation of KVStore

View File

@ -179,6 +179,6 @@ func (gi *gasIterator) Close() {
func (gi *gasIterator) consumeSeekGas() { func (gi *gasIterator) consumeSeekGas() {
value := gi.Value() value := gi.Value()
gi.gasMeter.ConsumeGas(gi.gasConfig.ValueCostPerByte*sdk.Gas(len(value)), sdk.GasValuePerByteDesc) gi.gasMeter.ConsumeGas(gi.gasConfig.ReadCostPerByte*sdk.Gas(len(value)), sdk.GasValuePerByteDesc)
gi.gasMeter.ConsumeGas(gi.gasConfig.IterNextCostFlat, sdk.GasIterNextCostFlatDesc) gi.gasMeter.ConsumeGas(gi.gasConfig.IterNextCostFlat, sdk.GasIterNextCostFlatDesc)
} }

View File

@ -12,26 +12,26 @@ import (
) )
func newGasKVStore() KVStore { func newGasKVStore() KVStore {
meter := sdk.NewGasMeter(1000) meter := sdk.NewGasMeter(10000)
mem := dbStoreAdapter{dbm.NewMemDB()} mem := dbStoreAdapter{dbm.NewMemDB()}
return NewGasKVStore(meter, sdk.KVGasConfig(), mem) return NewGasKVStore(meter, sdk.KVGasConfig(), mem)
} }
func TestGasKVStoreBasic(t *testing.T) { func TestGasKVStoreBasic(t *testing.T) {
mem := dbStoreAdapter{dbm.NewMemDB()} mem := dbStoreAdapter{dbm.NewMemDB()}
meter := sdk.NewGasMeter(1000) meter := sdk.NewGasMeter(10000)
st := NewGasKVStore(meter, sdk.KVGasConfig(), mem) st := NewGasKVStore(meter, sdk.KVGasConfig(), mem)
require.Empty(t, st.Get(keyFmt(1)), "Expected `key1` to be empty") require.Empty(t, st.Get(keyFmt(1)), "Expected `key1` to be empty")
st.Set(keyFmt(1), valFmt(1)) st.Set(keyFmt(1), valFmt(1))
require.Equal(t, valFmt(1), st.Get(keyFmt(1))) require.Equal(t, valFmt(1), st.Get(keyFmt(1)))
st.Delete(keyFmt(1)) st.Delete(keyFmt(1))
require.Empty(t, st.Get(keyFmt(1)), "Expected `key1` to be empty") require.Empty(t, st.Get(keyFmt(1)), "Expected `key1` to be empty")
require.Equal(t, meter.GasConsumed(), sdk.Gas(193)) require.Equal(t, meter.GasConsumed(), sdk.Gas(6429))
} }
func TestGasKVStoreIterator(t *testing.T) { func TestGasKVStoreIterator(t *testing.T) {
mem := dbStoreAdapter{dbm.NewMemDB()} mem := dbStoreAdapter{dbm.NewMemDB()}
meter := sdk.NewGasMeter(1000) meter := sdk.NewGasMeter(10000)
st := NewGasKVStore(meter, sdk.KVGasConfig(), mem) st := NewGasKVStore(meter, sdk.KVGasConfig(), mem)
require.Empty(t, st.Get(keyFmt(1)), "Expected `key1` to be empty") require.Empty(t, st.Get(keyFmt(1)), "Expected `key1` to be empty")
require.Empty(t, st.Get(keyFmt(2)), "Expected `key2` to be empty") require.Empty(t, st.Get(keyFmt(2)), "Expected `key2` to be empty")
@ -50,7 +50,7 @@ func TestGasKVStoreIterator(t *testing.T) {
iterator.Next() iterator.Next()
require.False(t, iterator.Valid()) require.False(t, iterator.Valid())
require.Panics(t, iterator.Next) require.Panics(t, iterator.Next)
require.Equal(t, meter.GasConsumed(), sdk.Gas(384)) require.Equal(t, meter.GasConsumed(), sdk.Gas(6987))
} }
func TestGasKVStoreOutOfGasSet(t *testing.T) { func TestGasKVStoreOutOfGasSet(t *testing.T) {
@ -62,7 +62,7 @@ func TestGasKVStoreOutOfGasSet(t *testing.T) {
func TestGasKVStoreOutOfGasIterator(t *testing.T) { func TestGasKVStoreOutOfGasIterator(t *testing.T) {
mem := dbStoreAdapter{dbm.NewMemDB()} mem := dbStoreAdapter{dbm.NewMemDB()}
meter := sdk.NewGasMeter(200) meter := sdk.NewGasMeter(20000)
st := NewGasKVStore(meter, sdk.KVGasConfig(), mem) st := NewGasKVStore(meter, sdk.KVGasConfig(), mem)
st.Set(keyFmt(1), valFmt(1)) st.Set(keyFmt(1), valFmt(1))
iterator := st.Iterator(nil, nil) iterator := st.Iterator(nil, nil)
@ -71,7 +71,7 @@ func TestGasKVStoreOutOfGasIterator(t *testing.T) {
} }
func testGasKVStoreWrap(t *testing.T, store KVStore) { func testGasKVStoreWrap(t *testing.T, store KVStore) {
meter := sdk.NewGasMeter(10000) meter := sdk.NewGasMeter(100000)
store = store.Gas(meter, sdk.GasConfig{HasCost: 10}) store = store.Gas(meter, sdk.GasConfig{HasCost: 10})
require.Equal(t, uint64(0), meter.GasConsumed()) require.Equal(t, uint64(0), meter.GasConsumed())

View File

@ -4,8 +4,9 @@ import (
"math/rand" "math/rand"
"testing" "testing"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
) )
func TestList(t *testing.T) { func TestList(t *testing.T) {

View File

@ -3,10 +3,11 @@ package store
import ( import (
"testing" "testing"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
dbm "github.com/tendermint/tendermint/libs/db" dbm "github.com/tendermint/tendermint/libs/db"
sdk "github.com/cosmos/cosmos-sdk/types"
) )
func TestVerifyIAVLStoreQueryProof(t *testing.T) { func TestVerifyIAVLStoreQueryProof(t *testing.T) {

View File

@ -1,8 +1,9 @@
package store package store
import ( import (
sdk "github.com/cosmos/cosmos-sdk/types"
dbm "github.com/tendermint/tendermint/libs/db" dbm "github.com/tendermint/tendermint/libs/db"
sdk "github.com/cosmos/cosmos-sdk/types"
) )
var _ KVStore = (*transientStore)(nil) var _ KVStore = (*transientStore)(nil)

View File

@ -8,9 +8,10 @@ import (
dbm "github.com/tendermint/tendermint/libs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/cosmos/cosmos-sdk/store" "github.com/cosmos/cosmos-sdk/store"
"github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types"
) )
type MockLogger struct { type MockLogger struct {

View File

@ -400,6 +400,11 @@ func (d Dec) TruncateInt() Int {
return NewIntFromBigInt(chopPrecisionAndTruncateNonMutative(d.Int)) return NewIntFromBigInt(chopPrecisionAndTruncateNonMutative(d.Int))
} }
// TruncateDec truncates the decimals from the number and returns a Dec
func (d Dec) TruncateDec() Dec {
return NewDecFromBigInt(chopPrecisionAndTruncateNonMutative(d.Int))
}
//___________________________________________________________________________________ //___________________________________________________________________________________
// reuse nil values // reuse nil values

View File

@ -6,8 +6,9 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/codec"
) )
// create a decimal from a decimal string (ex. "1234.5678") // create a decimal from a decimal string (ex. "1234.5678")

View File

@ -4,9 +4,10 @@ import (
"fmt" "fmt"
"strings" "strings"
"github.com/cosmos/cosmos-sdk/codec"
cmn "github.com/tendermint/tendermint/libs/common" cmn "github.com/tendermint/tendermint/libs/common"
"github.com/cosmos/cosmos-sdk/codec"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
) )
@ -43,6 +44,7 @@ const (
CodeMemoTooLarge CodeType = 13 CodeMemoTooLarge CodeType = 13
CodeInsufficientFee CodeType = 14 CodeInsufficientFee CodeType = 14
CodeTooManySignatures CodeType = 15 CodeTooManySignatures CodeType = 15
CodeGasOverflow CodeType = 16
// CodespaceRoot is a codespace for error codes in this file only. // CodespaceRoot is a codespace for error codes in this file only.
// Notice that 0 is an "unset" codespace, which can be overridden with // Notice that 0 is an "unset" codespace, which can be overridden with
@ -143,6 +145,9 @@ func ErrInsufficientFee(msg string) Error {
func ErrTooManySignatures(msg string) Error { func ErrTooManySignatures(msg string) Error {
return newErrorWithRootCodespace(CodeTooManySignatures, msg) return newErrorWithRootCodespace(CodeTooManySignatures, msg)
} }
func ErrGasOverflow(msg string) Error {
return newErrorWithRootCodespace(CodeGasOverflow, msg)
}
//---------------------------------------- //----------------------------------------
// Error & sdkError // Error & sdkError

View File

@ -140,21 +140,19 @@ type GasConfig struct {
ReadCostPerByte Gas ReadCostPerByte Gas
WriteCostFlat Gas WriteCostFlat Gas
WriteCostPerByte Gas WriteCostPerByte Gas
ValueCostPerByte Gas
IterNextCostFlat Gas IterNextCostFlat Gas
} }
// KVGasConfig returns a default gas config for KVStores. // KVGasConfig returns a default gas config for KVStores.
func KVGasConfig() GasConfig { func KVGasConfig() GasConfig {
return GasConfig{ return GasConfig{
HasCost: 10, HasCost: 1000,
DeleteCost: 10, DeleteCost: 1000,
ReadCostFlat: 10, ReadCostFlat: 1000,
ReadCostPerByte: 1, ReadCostPerByte: 3,
WriteCostFlat: 10, WriteCostFlat: 2000,
WriteCostPerByte: 10, WriteCostPerByte: 30,
ValueCostPerByte: 1, IterNextCostFlat: 30,
IterNextCostFlat: 15,
} }
} }

View File

@ -3,9 +3,10 @@ package auth
import ( import (
"errors" "errors"
"github.com/tendermint/tendermint/crypto"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/tendermint/tendermint/crypto"
) )
// Account is an interface used to store coins at a given address within state. // Account is an interface used to store coins at a given address within state.

View File

@ -5,20 +5,21 @@ import (
"encoding/hex" "encoding/hex"
"fmt" "fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/crypto/ed25519"
"github.com/tendermint/tendermint/crypto/secp256k1" "github.com/tendermint/tendermint/crypto/secp256k1"
sdk "github.com/cosmos/cosmos-sdk/types"
) )
const ( const (
memoCostPerByte sdk.Gas = 1 memoCostPerByte sdk.Gas = 3
ed25519VerifyCost = 59 ed25519VerifyCost = 590
secp256k1VerifyCost = 100 secp256k1VerifyCost = 1000
maxMemoCharacters = 100 maxMemoCharacters = 256
// how much gas = 1 atom // how much gas = 1 atom
gasPerUnitCost = 1000 gasPerUnitCost = 10000
// max total number of sigs per tx // max total number of sigs per tx
txSigLimit = 7 txSigLimit = 7

View File

@ -2,10 +2,9 @@ package auth
import ( import (
"fmt" "fmt"
"strings"
"testing" "testing"
codec "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
@ -13,6 +12,9 @@ import (
"github.com/tendermint/tendermint/crypto/multisig" "github.com/tendermint/tendermint/crypto/multisig"
"github.com/tendermint/tendermint/crypto/secp256k1" "github.com/tendermint/tendermint/crypto/secp256k1"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
codec "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
) )
func newTestMsg(addrs ...sdk.AccAddress) *sdk.TestMsg { func newTestMsg(addrs ...sdk.AccAddress) *sdk.TestMsg {
@ -20,7 +22,7 @@ func newTestMsg(addrs ...sdk.AccAddress) *sdk.TestMsg {
} }
func newStdFee() StdFee { func newStdFee() StdFee {
return NewStdFee(5000, return NewStdFee(50000,
sdk.NewInt64Coin("atom", 150), sdk.NewInt64Coin("atom", 150),
) )
} }
@ -437,13 +439,13 @@ func TestAnteHandlerMemoGas(t *testing.T) {
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeOutOfGas) checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeOutOfGas)
// memo too large // memo too large
fee = NewStdFee(2001, sdk.NewInt64Coin("atom", 0)) fee = NewStdFee(9000, sdk.NewInt64Coin("atom", 0))
tx = newTestTxWithMemo(ctx, []sdk.Msg{msg}, privs, accnums, seqs, fee, "abcininasidniandsinasindiansdiansdinaisndiasndiadninsdabcininasidniandsinasindiansdiansdinaisndiasndiadninsdabcininasidniandsinasindiansdiansdinaisndiasndiadninsd") tx = newTestTxWithMemo(ctx, []sdk.Msg{msg}, privs, accnums, seqs, fee, strings.Repeat("01234567890", 500))
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeMemoTooLarge) checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeMemoTooLarge)
// tx with memo has enough gas // tx with memo has enough gas
fee = NewStdFee(1100, sdk.NewInt64Coin("atom", 0)) fee = NewStdFee(9000, sdk.NewInt64Coin("atom", 0))
tx = newTestTxWithMemo(ctx, []sdk.Msg{msg}, privs, accnums, seqs, fee, "abcininasidniandsinasindiansdiansdinaisndiasndiadninsd") tx = newTestTxWithMemo(ctx, []sdk.Msg{msg}, privs, accnums, seqs, fee, strings.Repeat("0123456789", 10))
checkValidTx(t, anteHandler, ctx, tx, false) checkValidTx(t, anteHandler, ctx, tx, false)
} }
@ -706,8 +708,8 @@ func TestAdjustFeesByGas(t *testing.T) {
args args args args
want sdk.Coins want sdk.Coins
}{ }{
{"nil coins", args{sdk.Coins{}, 10000}, sdk.Coins{}}, {"nil coins", args{sdk.Coins{}, 100000}, sdk.Coins{}},
{"nil coins", args{sdk.Coins{sdk.NewInt64Coin("A", 10), sdk.NewInt64Coin("B", 0)}, 10000}, sdk.Coins{sdk.NewInt64Coin("A", 20), sdk.NewInt64Coin("B", 10)}}, {"nil coins", args{sdk.Coins{sdk.NewInt64Coin("A", 10), sdk.NewInt64Coin("B", 0)}, 100000}, sdk.Coins{sdk.NewInt64Coin("A", 20), sdk.NewInt64Coin("B", 10)}},
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {

View File

@ -6,15 +6,16 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/tendermint/go-amino"
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/client/utils" "github.com/cosmos/cosmos-sdk/client/utils"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder" authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/tendermint/go-amino"
) )
const ( const (

View File

@ -6,11 +6,12 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto/ed25519"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types"
"github.com/tendermint/tendermint/crypto/ed25519"
) )
var ( var (

Some files were not shown because too many files have changed in this diff Show More