Merge branch 'develop' into rigel/stake-spec-compliance

This commit is contained in:
Rigel 2018-07-02 21:03:46 -04:00 committed by GitHub
commit 2a2f5db450
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
84 changed files with 486 additions and 453 deletions

View File

@ -5,37 +5,43 @@
*TBD* *TBD*
BREAKING CHANGES BREAKING CHANGES
* Change default ports from 466xx to 266xx * Update Tendermint to v0.22.0
* AltBytes renamed to Memo, now a string, max 100 characters, costs a bit of gas * Default ports changed from 466xx to 266xx
* Transactions now take a list of Messages * Amino JSON uses type names instead of prefix bytes
* Signers of a transaction now only sign over their account and sequence number * ED25519 addresses are the first 20-bytes of the SHA256 of the raw 32-byte
* Removed MsgChangePubKey from auth pubkey
* Removed setPubKey from account mapper * go-crypto, abci, tmlibs have been merged into Tendermint
* Removed GetMemo from Tx (it is still on StdTx) * Various other fixes
* Keybase and Ledger support from go-crypto merged into the SDK in the `crypto` folder * [auth] Signers of a transaction now only sign over their own account and sequence number
* Gov module REST endpoints changed to be more RESTful * [auth] Removed MsgChangePubKey
* [cli] rearranged commands under subcommands * [auth] Removed SetPubKey from account mapper
* [stake] remove Tick and add EndBlocker * [auth] AltBytes renamed to Memo, now a string, max 100 characters, costs a bit of gas
* [stake] introduce concept of unbonding for delegations and validators * [types] `GetMsg()` -> `GetMsgs()` as txs wrap many messages
* [types] Removed GetMemo from Tx (it is still on StdTx)
* [types] renamed rational.Evaluate to rational.Round{Int64, Int}
* [keys] Keybase and Ledger support from go-crypto merged into the SDK in the `crypto` folder
* [cli] Rearranged commands under subcommands
* [x/gov] Gov module REST endpoints changed to be more RESTful
* [x/stake] Remove Tick and add EndBlocker
* [x/stake] Introduce concept of unbonding for delegations and validators
* `gaiacli stake unbond` replaced with `gaiacli stake begin-unbonding` * `gaiacli stake unbond` replaced with `gaiacli stake begin-unbonding`
* introduced: * Introduced:
* `gaiacli stake complete-unbonding` * `gaiacli stake complete-unbonding`
* `gaiacli stake begin-redelegation` * `gaiacli stake begin-redelegation`
* `gaiacli stake complete-redelegation` * `gaiacli stake complete-redelegation`
* [slashing] update slashing for unbonding period * [x/slashing] Update slashing for unbonding period
* Slash according to power at time of infraction instead of power at * Slash according to power at time of infraction instead of power at
time of discovery time of discovery
* Iterate through unbonding delegations & redelegations which contributed * Iterate through unbonding delegations & redelegations which contributed
to an infraction, slash them proportional to their stake at the time to an infraction, slash them proportional to their stake at the time
* Add REST endpoint to unrevoke a validator previously revoked for downtime * Add REST endpoint to unrevoke a validator previously revoked for downtime
* Add REST endpoint to retrieve liveness signing information for a validator * Add REST endpoint to retrieve liveness signing information for a validator
* [types] renamed rational.Evaluate to rational.Round{Int64, Int}
FEATURES FEATURES
* [gaiacli] You can now attach a simple text-only memo to any transaction, with the `--memo` flag * [gaiacli] You can now attach a simple text-only memo to any transaction, with the `--memo` flag
* [lcd] Queried TXs now include the tx hash to identify each tx * [lcd] Queried TXs now include the tx hash to identify each tx
* [mockapp] CompleteSetup() no longer takes a testing parameter * [mockapp] CompleteSetup() no longer takes a testing parameter
* [governance] Implemented MVP * [x/gov] Implemented MVP
* Supported proposal types: just binary (pass/fail) TextProposals for now * Supported proposal types: just binary (pass/fail) TextProposals for now
* Proposals need deposits to be votable; deposits are burned if proposal fails * Proposals need deposits to be votable; deposits are burned if proposal fails
* Delegators delegate votes to validator by default but can override (for their stake) * Delegators delegate votes to validator by default but can override (for their stake)
@ -55,14 +61,25 @@ FEATURES
* [server] Default config now creates a profiler at port 6060, and increase p2p send/recv rates * [server] Default config now creates a profiler at port 6060, and increase p2p send/recv rates
* [tests] Add WaitForNextNBlocksTM helper method * [tests] Add WaitForNextNBlocksTM helper method
* [types] Switches internal representation of Int/Uint/Rat to use pointers * [types] Switches internal representation of Int/Uint/Rat to use pointers
* [gaiad] unsafe_reset_all now resets addrbook.json * [gaiad] `unsafe_reset_all` now resets addrbook.json
* [democoin] add x/oracle, x/assoc * [democoin] add x/oracle, x/assoc
* [gaiacli] Ledger support added * [gaiacli] Ledger support added
- You can now use a Ledger with `gaiacli --ledger` for all key-related commands - You can now use a Ledger with `gaiacli --ledger` for all key-related commands
- Ledger keys can be named and tracked locally in the key DB - Ledger keys can be named and tracked locally in the key DB
* [gaiacli] added an --async flag to the cli to deliver transactions without waiting for a tendermint response * [gaiacli] added an --async flag to the cli to deliver transactions without waiting for a tendermint response
FIXES IMPROVEMENTS
* bank module uses go-wire codec instead of 'encoding/json'
* auth module uses go-wire codec instead of 'encoding/json'
* revised use of endblock and beginblock
* [stake] module reorganized to include `types` and `keeper` package
* [stake] keeper always loads the store (instead passing around which doesn't really boost efficiency)
* [stake] edit-validator changes now can use the keyword [do-not-modify] to not modify unspecified `--flag` (aka won't set them to `""` value)
* [types] added common tag constants
* [stake] offload more generic functionality from the handler into the keeper
* added contributing guidelines
BUG FIXES
* [gaia] Added self delegation for validators in the genesis creation * [gaia] Added self delegation for validators in the genesis creation
* [lcd] tests now don't depend on raw json text * [lcd] tests now don't depend on raw json text
* [stake] error strings lower case * [stake] error strings lower case
@ -78,17 +95,6 @@ FIXES
* \#1258 - printing big.rat's can no longer overflow int64 * \#1258 - printing big.rat's can no longer overflow int64
* \#887 - limit the size of rationals that can be passed in from user input * \#887 - limit the size of rationals that can be passed in from user input
IMPROVEMENTS
* bank module uses go-wire codec instead of 'encoding/json'
* auth module uses go-wire codec instead of 'encoding/json'
* revised use of endblock and beginblock
* [stake] module reorganized to include `types` and `keeper` package
* [stake] keeper always loads the store (instead passing around which doesn't really boost efficiency)
* [stake] edit-validator changes now can use the keyword [do-not-modify] to not modify unspecified `--flag` (aka won't set them to `""` value)
* [types] added common tag constants
* [stake] offload more generic functionality from the handler into the keeper
* added contributing guidelines
## 0.19.0 ## 0.19.0
*June 13, 2018* *June 13, 2018*

64
Gopkg.lock generated
View File

@ -137,7 +137,6 @@
".", ".",
"hcl/ast", "hcl/ast",
"hcl/parser", "hcl/parser",
"hcl/printer",
"hcl/scanner", "hcl/scanner",
"hcl/strconv", "hcl/strconv",
"hcl/token", "hcl/token",
@ -241,7 +240,7 @@
"nfs", "nfs",
"xfs" "xfs"
] ]
revision = "7d6f385de8bea29190f15ba9931442a0eaef9af7" revision = "40f013a808ec4fa79def444a1a56de4d1727efcb"
[[projects]] [[projects]]
branch = "master" branch = "master"
@ -267,8 +266,8 @@
[[projects]] [[projects]]
name = "github.com/spf13/cobra" name = "github.com/spf13/cobra"
packages = ["."] packages = ["."]
revision = "ef82de70bb3f60c65fb8eebacbb2d122ef517385" revision = "7b2c5ac9fc04fc5efafb60700713d4fa609b777b"
version = "v0.0.3" version = "v0.0.1"
[[projects]] [[projects]]
branch = "master" branch = "master"
@ -285,8 +284,8 @@
[[projects]] [[projects]]
name = "github.com/spf13/viper" name = "github.com/spf13/viper"
packages = ["."] packages = ["."]
revision = "b5e8006cbee93ec955a89ab31e0e3ce3204f3736" revision = "25b30aa063fc18e48662b86996252eabdcf2f0c7"
version = "v1.0.2" version = "v1.0.0"
[[projects]] [[projects]]
name = "github.com/stretchr/testify" name = "github.com/stretchr/testify"
@ -334,11 +333,9 @@
[[projects]] [[projects]]
name = "github.com/tendermint/iavl" name = "github.com/tendermint/iavl"
packages = [ packages = ["."]
".", revision = "9e5dc3e61f70b285bb25414452d47aca1ff34c1d"
"sha256truncated" version = "v0.8.2-rc0"
]
revision = "481b89cbbe6a641f7f6cb5db92b30b20f5a2e001"
[[projects]] [[projects]]
name = "github.com/tendermint/tendermint" name = "github.com/tendermint/tendermint"
@ -354,9 +351,19 @@
"consensus", "consensus",
"consensus/types", "consensus/types",
"crypto", "crypto",
"crypto/merkle",
"crypto/tmhash", "crypto/tmhash",
"evidence", "evidence",
"libs/autofile",
"libs/bech32",
"libs/cli",
"libs/cli/flags",
"libs/clist",
"libs/common",
"libs/db",
"libs/events", "libs/events",
"libs/flowrate",
"libs/log",
"libs/pubsub", "libs/pubsub",
"libs/pubsub/query", "libs/pubsub/query",
"lite", "lite",
@ -387,25 +394,8 @@
"types", "types",
"version" "version"
] ]
revision = "8412b75b1070ac023405e8228e017ed36531fe1b" revision = "5923b6288fe8ce9581936ee97c2bf9cf9c02c2f4"
version = "v0.22.0-rc2"
[[projects]]
name = "github.com/tendermint/tmlibs"
packages = [
"autofile",
"bech32",
"cli",
"cli/flags",
"clist",
"common",
"db",
"flowrate",
"log",
"merkle",
"merkle/tmhash"
]
revision = "49596e0a1f48866603813df843c9409fc19805c6"
version = "v0.9.0"
[[projects]] [[projects]]
name = "github.com/zondax/ledger-goclient" name = "github.com/zondax/ledger-goclient"
@ -443,7 +433,7 @@
"netutil", "netutil",
"trace" "trace"
] ]
revision = "97aa3a539ec716117a9d15a4659a911f50d13c3c" revision = "87b3feba568e144938625fc5d80ec92566c1a8fe"
[[projects]] [[projects]]
branch = "master" branch = "master"
@ -482,9 +472,13 @@
packages = [ packages = [
".", ".",
"balancer", "balancer",
"balancer/base",
"balancer/roundrobin",
"codes", "codes",
"connectivity", "connectivity",
"credentials", "credentials",
"encoding",
"encoding/proto",
"grpclb/grpc_lb_v1/messages", "grpclb/grpc_lb_v1/messages",
"grpclog", "grpclog",
"internal", "internal",
@ -493,13 +487,15 @@
"naming", "naming",
"peer", "peer",
"resolver", "resolver",
"resolver/dns",
"resolver/passthrough",
"stats", "stats",
"status", "status",
"tap", "tap",
"transport" "transport"
] ]
revision = "5b3c4e850e90a4cf6a20ebd46c8b32a0a3afcb9e" revision = "d11072e7ca9811b1100b80ca0269ac831f06d024"
version = "v1.7.5" version = "v1.11.3"
[[projects]] [[projects]]
name = "gopkg.in/yaml.v2" name = "gopkg.in/yaml.v2"
@ -510,6 +506,6 @@
[solve-meta] [solve-meta]
analyzer-name = "dep" analyzer-name = "dep"
analyzer-version = 1 analyzer-version = 1
inputs-digest = "578ae0e0126ffd04006b6755a02bc25c95e2eb2ecb4ea99869c4ada133f29f6b" inputs-digest = "13ad2a57b6942729e2d08b5c37810d62108aa64a335a4822fcff1ad992c0662b"
solver-name = "gps-cdcl" solver-name = "gps-cdcl"
solver-version = 1 solver-version = 1

View File

@ -58,11 +58,11 @@
[[constraint]] [[constraint]]
name = "github.com/tendermint/iavl" name = "github.com/tendermint/iavl"
revision = "481b89cbbe6a641f7f6cb5db92b30b20f5a2e001" version = "=v0.8.2-rc0"
[[constraint]] [[constraint]]
name = "github.com/tendermint/tendermint" name = "github.com/tendermint/tendermint"
revision = "8412b75b1070ac023405e8228e017ed36531fe1b" version = "=0.22.0-rc2"
[[constraint]] [[constraint]]
name = "github.com/tendermint/tmlibs" name = "github.com/tendermint/tmlibs"

View File

@ -8,9 +8,9 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
"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"

View File

@ -12,9 +12,9 @@ import (
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
tmtypes "github.com/tendermint/tendermint/types" tmtypes "github.com/tendermint/tendermint/types"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/wire" "github.com/cosmos/cosmos-sdk/wire"

View File

@ -3,7 +3,7 @@ package baseapp
import ( import (
"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/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
) )
// RunForever - BasecoinApp execution and cleanup // RunForever - BasecoinApp execution and cleanup

View File

@ -3,7 +3,7 @@ package context
import ( import (
"fmt" "fmt"
"github.com/tendermint/tmlibs/common" "github.com/tendermint/tendermint/libs/common"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -11,7 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
rpcclient "github.com/tendermint/tendermint/rpc/client" rpcclient "github.com/tendermint/tendermint/rpc/client"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
"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"

View File

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

View File

@ -15,7 +15,7 @@ import (
ccrypto "github.com/cosmos/cosmos-sdk/crypto" ccrypto "github.com/cosmos/cosmos-sdk/crypto"
"github.com/cosmos/cosmos-sdk/crypto/keys" "github.com/cosmos/cosmos-sdk/crypto/keys"
"github.com/tendermint/tmlibs/cli" "github.com/tendermint/tendermint/libs/cli"
) )
const ( const (

View File

@ -7,8 +7,8 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
keys "github.com/cosmos/cosmos-sdk/crypto/keys" keys "github.com/cosmos/cosmos-sdk/crypto/keys"
"github.com/tendermint/tmlibs/cli" "github.com/tendermint/tendermint/libs/cli"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"

View File

@ -15,7 +15,7 @@ import (
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
p2p "github.com/tendermint/tendermint/p2p" p2p "github.com/tendermint/tendermint/p2p"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
"github.com/tendermint/tmlibs/common" "github.com/tendermint/tendermint/libs/common"
client "github.com/cosmos/cosmos-sdk/client" client "github.com/cosmos/cosmos-sdk/client"
keys "github.com/cosmos/cosmos-sdk/client/keys" keys "github.com/cosmos/cosmos-sdk/client/keys"

View File

@ -7,10 +7,10 @@ import (
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
tmserver "github.com/tendermint/tendermint/rpc/lib/server" tmserver "github.com/tendermint/tendermint/rpc/lib/server"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
client "github.com/cosmos/cosmos-sdk/client" client "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"

View File

@ -24,9 +24,9 @@ import (
"github.com/tendermint/tendermint/proxy" "github.com/tendermint/tendermint/proxy"
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"
"github.com/tendermint/tmlibs/cli" "github.com/tendermint/tendermint/libs/cli"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
keys "github.com/cosmos/cosmos-sdk/client/keys" keys "github.com/cosmos/cosmos-sdk/client/keys"

View File

@ -6,7 +6,7 @@ import (
"net/http" "net/http"
"strconv" "strconv"
"github.com/tendermint/tmlibs/common" "github.com/tendermint/tendermint/libs/common"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/spf13/cobra" "github.com/spf13/cobra"

View File

@ -6,9 +6,9 @@ import (
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
tmtypes "github.com/tendermint/tendermint/types" tmtypes "github.com/tendermint/tendermint/types"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
bam "github.com/cosmos/cosmos-sdk/baseapp" bam "github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"

View File

@ -3,7 +3,7 @@ package main
import ( import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/tendermint/tmlibs/cli" "github.com/tendermint/tendermint/libs/cli"
"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"

View File

@ -7,9 +7,9 @@ import (
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
tmtypes "github.com/tendermint/tendermint/types" tmtypes "github.com/tendermint/tendermint/types"
"github.com/tendermint/tmlibs/cli" "github.com/tendermint/tendermint/libs/cli"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
"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"

View File

@ -10,9 +10,9 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
bam "github.com/cosmos/cosmos-sdk/baseapp" bam "github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"

View File

@ -8,7 +8,7 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
tcrypto "github.com/tendermint/tendermint/crypto" tcrypto "github.com/tendermint/tendermint/crypto"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/cosmos/cosmos-sdk/crypto" "github.com/cosmos/cosmos-sdk/crypto"
"github.com/cosmos/cosmos-sdk/crypto/keys/bip39" "github.com/cosmos/cosmos-sdk/crypto/keys/bip39"

View File

@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
) )
// TestKeyManagement makes sure we can manipulate these keys well // TestKeyManagement makes sure we can manipulate these keys well

View File

@ -4,7 +4,7 @@ import (
"encoding/hex" "encoding/hex"
"fmt" "fmt"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
"github.com/cosmos/cosmos-sdk/crypto/keys/bcrypt" "github.com/cosmos/cosmos-sdk/crypto/keys/bcrypt"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"

View File

@ -3,9 +3,9 @@ package app
import ( import (
"encoding/json" "encoding/json"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
bapp "github.com/cosmos/cosmos-sdk/baseapp" bapp "github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"

View File

@ -6,9 +6,9 @@ import (
"fmt" "fmt"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
bapp "github.com/cosmos/cosmos-sdk/baseapp" bapp "github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"

View File

@ -1,9 +1,9 @@
package app package app
import ( import (
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
bapp "github.com/cosmos/cosmos-sdk/baseapp" bapp "github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"

View File

@ -2,9 +2,9 @@ package app
import ( import (
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
bapp "github.com/cosmos/cosmos-sdk/baseapp" bapp "github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"

View File

@ -3,183 +3,174 @@ package app
import ( import (
"encoding/json" "encoding/json"
abci "github.com/tendermint/tendermint/abci/types"
tmtypes "github.com/tendermint/tendermint/types"
cmn "github.com/tendermint/tmlibs/common"
dbm "github.com/tendermint/tmlibs/db"
"github.com/tendermint/tmlibs/log"
bam "github.com/cosmos/cosmos-sdk/baseapp" bam "github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/examples/basecoin/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/wire" "github.com/cosmos/cosmos-sdk/wire"
"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"
"github.com/cosmos/cosmos-sdk/x/slashing" abci "github.com/tendermint/tendermint/abci/types"
"github.com/cosmos/cosmos-sdk/x/stake" cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/cosmos/cosmos-sdk/examples/basecoin/types" "github.com/tendermint/tendermint/libs/log"
tmtypes "github.com/tendermint/tendermint/types"
) )
const ( const (
appName = "BasecoinApp" appName = "BasecoinApp"
) )
// Extended ABCI application // BasecoinApp implements an extended ABCI application. It contains a BaseApp,
// a codec for serialization, KVStore keys for multistore state management, and
// various mappers and keepers to manage getting, setting, and serializing the
// integral app types.
type BasecoinApp struct { type BasecoinApp struct {
*bam.BaseApp *bam.BaseApp
cdc *wire.Codec cdc *wire.Codec
// keys to access the substores // keys to access the multistore
keyMain *sdk.KVStoreKey keyMain *sdk.KVStoreKey
keyAccount *sdk.KVStoreKey keyAccount *sdk.KVStoreKey
keyIBC *sdk.KVStoreKey keyIBC *sdk.KVStoreKey
keyStake *sdk.KVStoreKey
keySlashing *sdk.KVStoreKey
// Manage getting and setting accounts // manage getting and setting accounts
accountMapper auth.AccountMapper accountMapper auth.AccountMapper
feeCollectionKeeper auth.FeeCollectionKeeper feeCollectionKeeper auth.FeeCollectionKeeper
coinKeeper bank.Keeper coinKeeper bank.Keeper
ibcMapper ibc.Mapper ibcMapper ibc.Mapper
stakeKeeper stake.Keeper
slashingKeeper slashing.Keeper
} }
// NewBasecoinApp returns a reference to a new BasecoinApp given a logger and
// database. Internally, a codec is created along with all the necessary keys.
// In addition, all necessary mappers and keepers are created, routes
// registered, and finally the stores being mounted along with any necessary
// chain initialization.
func NewBasecoinApp(logger log.Logger, db dbm.DB) *BasecoinApp { func NewBasecoinApp(logger log.Logger, db dbm.DB) *BasecoinApp {
// create and register app-level codec for TXs and accounts
cdc := MakeCodec()
// Create app-level codec for txs and accounts. // create your application type
var cdc = MakeCodec()
// Create your application object.
var app = &BasecoinApp{ var app = &BasecoinApp{
BaseApp: bam.NewBaseApp(appName, cdc, logger, db), cdc: cdc,
cdc: cdc, BaseApp: bam.NewBaseApp(appName, cdc, logger, db),
keyMain: sdk.NewKVStoreKey("main"), keyMain: sdk.NewKVStoreKey("main"),
keyAccount: sdk.NewKVStoreKey("acc"), keyAccount: sdk.NewKVStoreKey("acc"),
keyIBC: sdk.NewKVStoreKey("ibc"), keyIBC: sdk.NewKVStoreKey("ibc"),
keyStake: sdk.NewKVStoreKey("stake"),
keySlashing: sdk.NewKVStoreKey("slashing"),
} }
// Define the accountMapper. // define and attach the mappers and keepers
app.accountMapper = auth.NewAccountMapper( app.accountMapper = auth.NewAccountMapper(
cdc, cdc,
app.keyAccount, // target store app.keyAccount, // target store
&types.AppAccount{}, // prototype &types.AppAccount{}, // prototype
) )
// add accountMapper/handlers
app.coinKeeper = bank.NewKeeper(app.accountMapper) app.coinKeeper = bank.NewKeeper(app.accountMapper)
app.ibcMapper = ibc.NewMapper(app.cdc, app.keyIBC, app.RegisterCodespace(ibc.DefaultCodespace)) app.ibcMapper = ibc.NewMapper(app.cdc, app.keyIBC, app.RegisterCodespace(ibc.DefaultCodespace))
app.stakeKeeper = stake.NewKeeper(app.cdc, app.keyStake, app.coinKeeper, app.RegisterCodespace(stake.DefaultCodespace))
app.slashingKeeper = slashing.NewKeeper(app.cdc, app.keySlashing, app.stakeKeeper, app.RegisterCodespace(slashing.DefaultCodespace))
// register message routes // register message routes
app.Router(). app.Router().
AddRoute("bank", bank.NewHandler(app.coinKeeper)). AddRoute("bank", bank.NewHandler(app.coinKeeper)).
AddRoute("ibc", ibc.NewHandler(app.ibcMapper, app.coinKeeper)). AddRoute("ibc", ibc.NewHandler(app.ibcMapper, app.coinKeeper))
AddRoute("stake", stake.NewHandler(app.stakeKeeper))
// Initialize BaseApp. // perform initialization logic
app.SetInitChainer(app.initChainer) app.SetInitChainer(app.initChainer)
app.SetBeginBlocker(app.BeginBlocker) app.SetBeginBlocker(app.BeginBlocker)
app.SetEndBlocker(app.EndBlocker) app.SetEndBlocker(app.EndBlocker)
app.SetAnteHandler(auth.NewAnteHandler(app.accountMapper, app.feeCollectionKeeper)) app.SetAnteHandler(auth.NewAnteHandler(app.accountMapper, app.feeCollectionKeeper))
app.MountStoresIAVL(app.keyMain, app.keyAccount, app.keyIBC, app.keyStake, app.keySlashing)
// mount the multistore and load the latest state
app.MountStoresIAVL(app.keyMain, app.keyAccount, app.keyIBC)
err := app.LoadLatestVersion(app.keyMain) err := app.LoadLatestVersion(app.keyMain)
if err != nil { if err != nil {
cmn.Exit(err.Error()) cmn.Exit(err.Error())
} }
return app return app
} }
// Custom tx codec // MakeCodec creates a new wire codec and registers all the necessary types
// with the codec.
func MakeCodec() *wire.Codec { func MakeCodec() *wire.Codec {
var cdc = wire.NewCodec() cdc := wire.NewCodec()
wire.RegisterCrypto(cdc) // Register crypto.
sdk.RegisterWire(cdc) // Register Msgs wire.RegisterCrypto(cdc)
sdk.RegisterWire(cdc)
bank.RegisterWire(cdc) bank.RegisterWire(cdc)
stake.RegisterWire(cdc)
slashing.RegisterWire(cdc)
ibc.RegisterWire(cdc) ibc.RegisterWire(cdc)
// register custom AppAccount // register custom types
cdc.RegisterInterface((*auth.Account)(nil), nil) cdc.RegisterInterface((*auth.Account)(nil), nil)
cdc.RegisterConcrete(&types.AppAccount{}, "basecoin/Account", nil) cdc.RegisterConcrete(&types.AppAccount{}, "basecoin/Account", nil)
return cdc return cdc
} }
// application updates every end block // BeginBlocker reflects logic to run before any TXs application are processed
func (app *BasecoinApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { // by the application.
tags := slashing.BeginBlocker(ctx, req, app.slashingKeeper) func (app *BasecoinApp) BeginBlocker(_ sdk.Context, _ abci.RequestBeginBlock) abci.ResponseBeginBlock {
return abci.ResponseBeginBlock{}
return abci.ResponseBeginBlock{
Tags: tags.ToKVPairs(),
}
} }
// application updates every end block // EndBlocker reflects logic to run after all TXs are processed by the
// nolint: unparam // application.
func (app *BasecoinApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { func (app *BasecoinApp) EndBlocker(_ sdk.Context, _ abci.RequestEndBlock) abci.ResponseEndBlock {
validatorUpdates := stake.EndBlocker(ctx, app.stakeKeeper) return abci.ResponseEndBlock{}
return abci.ResponseEndBlock{
ValidatorUpdates: validatorUpdates,
}
} }
// Custom logic for basecoin initialization // initChainer implements the custom application logic that the BaseApp will
// invoke upon initialization. In this case, it will take the application's
// state provided by 'req' and attempt to deserialize said state. The state
// should contain all the genesis accounts. These accounts will be added to the
// application's account mapper.
func (app *BasecoinApp) initChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { func (app *BasecoinApp) initChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain {
stateJSON := req.AppStateBytes stateJSON := req.AppStateBytes
genesisState := new(types.GenesisState) genesisState := new(types.GenesisState)
err := app.cdc.UnmarshalJSON(stateJSON, genesisState) err := app.cdc.UnmarshalJSON(stateJSON, genesisState)
if err != nil { if err != nil {
panic(err) // TODO https://github.com/cosmos/cosmos-sdk/issues/468 // TODO: https://github.com/cosmos/cosmos-sdk/issues/468
// return sdk.ErrGenesisParse("").TraceCause(err, "") panic(err)
} }
for _, gacc := range genesisState.Accounts { for _, gacc := range genesisState.Accounts {
acc, err := gacc.ToAppAccount() acc, err := gacc.ToAppAccount()
if err != nil { if err != nil {
panic(err) // TODO https://github.com/cosmos/cosmos-sdk/issues/468 // TODO: https://github.com/cosmos/cosmos-sdk/issues/468
// return sdk.ErrGenesisParse("").TraceCause(err, "") panic(err)
} }
acc.AccountNumber = app.accountMapper.GetNextAccountNumber(ctx) acc.AccountNumber = app.accountMapper.GetNextAccountNumber(ctx)
app.accountMapper.SetAccount(ctx, acc) app.accountMapper.SetAccount(ctx, acc)
} }
// load the initial stake information
stake.InitGenesis(ctx, app.stakeKeeper, genesisState.StakeData)
return abci.ResponseInitChain{} return abci.ResponseInitChain{}
} }
// Custom logic for state export // ExportAppStateAndValidators implements custom application logic that exposes
// various parts of the application's state and set of validators. An error is
// returned if any step getting the state or set of validators fails.
func (app *BasecoinApp) ExportAppStateAndValidators() (appState json.RawMessage, validators []tmtypes.GenesisValidator, err error) { func (app *BasecoinApp) ExportAppStateAndValidators() (appState json.RawMessage, validators []tmtypes.GenesisValidator, err error) {
ctx := app.NewContext(true, abci.Header{}) ctx := app.NewContext(true, abci.Header{})
// iterate to get the accounts
accounts := []*types.GenesisAccount{} accounts := []*types.GenesisAccount{}
appendAccount := func(acc auth.Account) (stop bool) {
appendAccountsFn := func(acc auth.Account) bool {
account := &types.GenesisAccount{ account := &types.GenesisAccount{
Address: acc.GetAddress(), Address: acc.GetAddress(),
Coins: acc.GetCoins(), Coins: acc.GetCoins(),
} }
accounts = append(accounts, account) accounts = append(accounts, account)
return false return false
} }
app.accountMapper.IterateAccounts(ctx, appendAccount)
genState := types.GenesisState{ app.accountMapper.IterateAccounts(ctx, appendAccountsFn)
Accounts: accounts,
StakeData: stake.WriteGenesis(ctx, app.stakeKeeper), genState := types.GenesisState{Accounts: accounts}
}
appState, err = wire.MarshalJSONIndent(app.cdc, genState) appState, err = wire.MarshalJSONIndent(app.cdc, genState)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
validators = stake.WriteValidators(ctx, app.stakeKeeper)
return appState, validators, err return appState, validators, err
} }

View File

@ -1,88 +1,81 @@
package app package app
import ( import (
"fmt"
"os" "os"
"testing" "testing"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/examples/basecoin/types" "github.com/cosmos/cosmos-sdk/examples/basecoin/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/wire" "github.com/cosmos/cosmos-sdk/wire"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/stake" "github.com/stretchr/testify/require"
gen "github.com/cosmos/cosmos-sdk/x/stake/types"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
) )
func setGenesis(bapp *BasecoinApp, accs ...auth.BaseAccount) error { func setGenesis(baseApp *BasecoinApp, accounts ...*types.AppAccount) (types.GenesisState, error) {
genaccs := make([]*types.GenesisAccount, len(accs)) genAccts := make([]*types.GenesisAccount, len(accounts))
for i, acc := range accs { for i, appAct := range accounts {
genaccs[i] = types.NewGenesisAccount(&types.AppAccount{acc, "foobart"}) genAccts[i] = types.NewGenesisAccount(appAct)
} }
genesisState := types.GenesisState{ genesisState := types.GenesisState{Accounts: genAccts}
Accounts: genaccs, stateBytes, err := wire.MarshalJSONIndent(baseApp.cdc, genesisState)
StakeData: stake.DefaultGenesisState(),
}
stateBytes, err := wire.MarshalJSONIndent(bapp.cdc, genesisState)
if err != nil { if err != nil {
return err return types.GenesisState{}, err
} }
// Initialize the chain // initialize and commit the chain
vals := []abci.Validator{} baseApp.InitChain(abci.RequestInitChain{
bapp.InitChain(abci.RequestInitChain{Validators: vals, AppStateBytes: stateBytes}) Validators: []abci.Validator{}, AppStateBytes: stateBytes,
bapp.Commit() })
baseApp.Commit()
return nil return genesisState, nil
} }
//_______________________________________________________________________
func TestGenesis(t *testing.T) { func TestGenesis(t *testing.T) {
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "sdk/app") logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "sdk/app")
db := dbm.NewMemDB() db := dbm.NewMemDB()
bapp := NewBasecoinApp(logger, db) baseApp := NewBasecoinApp(logger, db)
// Construct some genesis bytes to reflect basecoin/types/AppAccount // construct a pubkey and an address for the test account
pk := crypto.GenPrivKeyEd25519().PubKey() pubkey := crypto.GenPrivKeyEd25519().PubKey()
addr := pk.Address() addr := pubkey.Address()
// construct some test coins
coins, err := sdk.ParseCoins("77foocoin,99barcoin") coins, err := sdk.ParseCoins("77foocoin,99barcoin")
require.Nil(t, err) require.Nil(t, err)
baseAcc := auth.BaseAccount{
Address: addr,
Coins: coins,
}
acc := &types.AppAccount{baseAcc, "foobart"}
err = setGenesis(bapp, baseAcc) // create an auth.BaseAccount for the given test account and set it's coins
baseAcct := auth.NewBaseAccountWithAddress(addr)
err = baseAcct.SetCoins(coins)
require.Nil(t, err) require.Nil(t, err)
// A checkTx context // create a new test AppAccount with the given auth.BaseAccount
ctx := bapp.BaseApp.NewContext(true, abci.Header{}) appAcct := types.NewAppAccount("foobar", baseAcct)
res1 := bapp.accountMapper.GetAccount(ctx, baseAcc.Address) genState, err := setGenesis(baseApp, appAcct)
require.Equal(t, acc, res1) require.Nil(t, err)
// create a context for the BaseApp
ctx := baseApp.BaseApp.NewContext(true, abci.Header{})
res := baseApp.accountMapper.GetAccount(ctx, baseAcct.Address)
require.Equal(t, appAcct, res)
// reload app and ensure the account is still there // reload app and ensure the account is still there
bapp = NewBasecoinApp(logger, db) baseApp = NewBasecoinApp(logger, db)
// Initialize stake data with default genesis state
stakedata := gen.DefaultGenesisState()
genState, err := bapp.cdc.MarshalJSON(stakedata)
if err != nil {
panic(err)
}
// InitChain with default stake data. Initializes deliverState and checkState context stateBytes, err := wire.MarshalJSONIndent(baseApp.cdc, genState)
bapp.InitChain(abci.RequestInitChain{AppStateBytes: []byte(fmt.Sprintf("{\"stake\": %s}", string(genState)))}) require.Nil(t, err)
ctx = bapp.BaseApp.NewContext(true, abci.Header{}) // initialize the chain with the expected genesis state
res1 = bapp.accountMapper.GetAccount(ctx, baseAcc.Address) baseApp.InitChain(abci.RequestInitChain{
require.Equal(t, acc, res1) Validators: []abci.Validator{}, AppStateBytes: stateBytes,
})
ctx = baseApp.BaseApp.NewContext(true, abci.Header{})
res = baseApp.accountMapper.GetAccount(ctx, baseAcct.Address)
require.Equal(t, appAcct, res)
} }

View File

@ -3,24 +3,20 @@ package main
import ( import (
"os" "os"
"github.com/spf13/cobra"
"github.com/tendermint/tmlibs/cli"
"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/lcd" "github.com/cosmos/cosmos-sdk/client/lcd"
"github.com/cosmos/cosmos-sdk/client/rpc" "github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/client/tx" "github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/examples/basecoin/app"
"github.com/cosmos/cosmos-sdk/examples/basecoin/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"
bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli" bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
ibccmd "github.com/cosmos/cosmos-sdk/x/ibc/client/cli" ibccmd "github.com/cosmos/cosmos-sdk/x/ibc/client/cli"
stakecmd "github.com/cosmos/cosmos-sdk/x/stake/client/cli" stakecmd "github.com/cosmos/cosmos-sdk/x/stake/client/cli"
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/examples/basecoin/app" "github.com/tendermint/tendermint/libs/cli"
"github.com/cosmos/cosmos-sdk/examples/basecoin/types"
) )
// rootCmd is the entry point for this binary // rootCmd is the entry point for this binary
@ -38,9 +34,9 @@ func main() {
// get the codec // get the codec
cdc := app.MakeCodec() cdc := app.MakeCodec()
// TODO: setup keybase, viper object, etc. to be passed into // TODO: Setup keybase, viper object, etc. to be passed into
// the below functions and eliminate global vars, like we do // the below functions and eliminate global vars, like we do
// with the cdc // with the cdc.
// add standard rpc, and tx commands // add standard rpc, and tx commands
rpc.AddCommands(rootCmd) rpc.AddCommands(rootCmd)
@ -82,7 +78,7 @@ func main() {
executor := cli.PrepareMainCmd(rootCmd, "BC", os.ExpandEnv("$HOME/.basecli")) executor := cli.PrepareMainCmd(rootCmd, "BC", os.ExpandEnv("$HOME/.basecli"))
err := executor.Execute() err := executor.Execute()
if err != nil { if err != nil {
// handle with #870 // Note: Handle with #870
panic(err) panic(err)
} }
} }

View File

@ -4,16 +4,14 @@ import (
"encoding/json" "encoding/json"
"os" "os"
"github.com/spf13/cobra"
abci "github.com/tendermint/tendermint/abci/types"
tmtypes "github.com/tendermint/tendermint/types"
"github.com/tendermint/tmlibs/cli"
dbm "github.com/tendermint/tmlibs/db"
"github.com/tendermint/tmlibs/log"
"github.com/cosmos/cosmos-sdk/examples/basecoin/app" "github.com/cosmos/cosmos-sdk/examples/basecoin/app"
"github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server"
"github.com/spf13/cobra"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/cli"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
tmtypes "github.com/tendermint/tendermint/types"
) )
func main() { func main() {
@ -33,9 +31,10 @@ func main() {
// prepare and add flags // prepare and add flags
rootDir := os.ExpandEnv("$HOME/.basecoind") rootDir := os.ExpandEnv("$HOME/.basecoind")
executor := cli.PrepareBaseCmd(rootCmd, "BC", rootDir) executor := cli.PrepareBaseCmd(rootCmd, "BC", rootDir)
err := executor.Execute() err := executor.Execute()
if err != nil { if err != nil {
// handle with #870 // Note: Handle with #870
panic(err) panic(err)
} }
} }

View File

@ -4,18 +4,17 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/wire" "github.com/cosmos/cosmos-sdk/wire"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/stake"
) )
var _ auth.Account = (*AppAccount)(nil) var _ auth.Account = (*AppAccount)(nil)
// Custom extensions for this application. This is just an example of // AppAccount is a custom extension for this application. It is an example of
// extending auth.BaseAccount with custom fields. // extending auth.BaseAccount with custom fields. It is compatible with the
// // stock auth.AccountStore, since auth.AccountStore uses the flexible go-amino
// This is compatible with the stock auth.AccountStore, since // library.
// auth.AccountStore uses the flexible go-amino library.
type AppAccount struct { type AppAccount struct {
auth.BaseAccount auth.BaseAccount
Name string `json:"name"` Name string `json:"name"`
} }
@ -23,36 +22,45 @@ type AppAccount struct {
func (acc AppAccount) GetName() string { return acc.Name } func (acc AppAccount) GetName() string { return acc.Name }
func (acc *AppAccount) SetName(name string) { acc.Name = name } func (acc *AppAccount) SetName(name string) { acc.Name = name }
// Get the AccountDecoder function for the custom AppAccount // NewAppAccount returns a reference to a new AppAccount given a name and an
// auth.BaseAccount.
func NewAppAccount(name string, baseAcct auth.BaseAccount) *AppAccount {
return &AppAccount{BaseAccount: baseAcct, Name: name}
}
// GetAccountDecoder returns the AccountDecoder function for the custom
// AppAccount.
func GetAccountDecoder(cdc *wire.Codec) auth.AccountDecoder { func GetAccountDecoder(cdc *wire.Codec) auth.AccountDecoder {
return func(accBytes []byte) (res auth.Account, err error) { return func(accBytes []byte) (auth.Account, error) {
if len(accBytes) == 0 { if len(accBytes) == 0 {
return nil, sdk.ErrTxDecode("accBytes are empty") return nil, sdk.ErrTxDecode("accBytes are empty")
} }
acct := new(AppAccount) acct := new(AppAccount)
err = cdc.UnmarshalBinaryBare(accBytes, &acct) err := cdc.UnmarshalBinaryBare(accBytes, &acct)
if err != nil { if err != nil {
panic(err) panic(err)
} }
return acct, err return acct, err
} }
} }
//___________________________________________________________________________________ // GenesisState reflects the genesis state of the application.
// State to Unmarshal
type GenesisState struct { type GenesisState struct {
Accounts []*GenesisAccount `json:"accounts"` Accounts []*GenesisAccount `json:"accounts"`
StakeData stake.GenesisState `json:"stake"`
} }
// GenesisAccount doesn't need pubkey or sequence // GenesisAccount reflects a genesis account the application expects in it's
// genesis state.
type GenesisAccount struct { type GenesisAccount struct {
Name string `json:"name"` Name string `json:"name"`
Address sdk.Address `json:"address"` Address sdk.Address `json:"address"`
Coins sdk.Coins `json:"coins"` Coins sdk.Coins `json:"coins"`
} }
// NewGenesisAccount returns a reference to a new GenesisAccount given an
// AppAccount.
func NewGenesisAccount(aa *AppAccount) *GenesisAccount { func NewGenesisAccount(aa *AppAccount) *GenesisAccount {
return &GenesisAccount{ return &GenesisAccount{
Name: aa.Name, Name: aa.Name,
@ -61,14 +69,13 @@ func NewGenesisAccount(aa *AppAccount) *GenesisAccount {
} }
} }
// convert GenesisAccount to AppAccount // ToAppAccount converts a GenesisAccount to an AppAccount.
func (ga *GenesisAccount) ToAppAccount() (acc *AppAccount, err error) { func (ga *GenesisAccount) ToAppAccount() (acc *AppAccount, err error) {
baseAcc := auth.BaseAccount{
Address: ga.Address,
Coins: ga.Coins.Sort(),
}
return &AppAccount{ return &AppAccount{
BaseAccount: baseAcc, Name: ga.Name,
Name: ga.Name, BaseAccount: auth.BaseAccount{
Address: ga.Address,
Coins: ga.Coins.Sort(),
},
}, nil }, nil
} }

View File

@ -5,9 +5,9 @@ import (
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
tmtypes "github.com/tendermint/tendermint/types" tmtypes "github.com/tendermint/tendermint/types"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
bam "github.com/cosmos/cosmos-sdk/baseapp" bam "github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"

View File

@ -14,8 +14,8 @@ import (
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
) )
func setGenesis(bapp *DemocoinApp, trend string, accs ...auth.BaseAccount) error { func setGenesis(bapp *DemocoinApp, trend string, accs ...auth.BaseAccount) error {

View File

@ -5,7 +5,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/tendermint/tmlibs/cli" "github.com/tendermint/tendermint/libs/cli"
"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"

View File

@ -8,9 +8,9 @@ import (
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
tmtypes "github.com/tendermint/tendermint/types" tmtypes "github.com/tendermint/tendermint/types"
"github.com/tendermint/tmlibs/cli" "github.com/tendermint/tendermint/libs/cli"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
"github.com/cosmos/cosmos-sdk/examples/democoin/app" "github.com/cosmos/cosmos-sdk/examples/democoin/app"
"github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server"

View File

@ -7,7 +7,7 @@ import (
"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/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/cosmos/cosmos-sdk/examples/democoin/mock" "github.com/cosmos/cosmos-sdk/examples/democoin/mock"
"github.com/cosmos/cosmos-sdk/store" "github.com/cosmos/cosmos-sdk/store"

View File

@ -6,7 +6,7 @@ import (
"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/tmlibs/db" 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"

View File

@ -7,7 +7,7 @@ import (
"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/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/cosmos/cosmos-sdk/examples/democoin/mock" "github.com/cosmos/cosmos-sdk/examples/democoin/mock"
"github.com/cosmos/cosmos-sdk/store" "github.com/cosmos/cosmos-sdk/store"

View File

@ -6,7 +6,7 @@ import (
"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/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
wire "github.com/cosmos/cosmos-sdk/wire" wire "github.com/cosmos/cosmos-sdk/wire"

View File

@ -6,8 +6,8 @@ import (
"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/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
"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"

View File

@ -9,8 +9,8 @@ import (
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
"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"

View File

@ -8,10 +8,10 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/tendermint/tendermint/abci/server" "github.com/tendermint/tendermint/abci/server"
"github.com/tendermint/tmlibs/cli" "github.com/tendermint/tendermint/libs/cli"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
bam "github.com/cosmos/cosmos-sdk/baseapp" bam "github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"

View File

@ -6,8 +6,8 @@ import (
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
tmtypes "github.com/tendermint/tendermint/types" tmtypes "github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
) )
// AppCreator lets us lazily initialize app, using home dir // AppCreator lets us lazily initialize app, using home dir

View File

@ -21,9 +21,9 @@ import (
"github.com/tendermint/tendermint/p2p" "github.com/tendermint/tendermint/p2p"
pvm "github.com/tendermint/tendermint/privval" pvm "github.com/tendermint/tendermint/privval"
tmtypes "github.com/tendermint/tendermint/types" tmtypes "github.com/tendermint/tendermint/types"
tmcli "github.com/tendermint/tmlibs/cli" tmcli "github.com/tendermint/tendermint/libs/cli"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
clkeys "github.com/cosmos/cosmos-sdk/client/keys" clkeys "github.com/cosmos/cosmos-sdk/client/keys"
serverconfig "github.com/cosmos/cosmos-sdk/server/config" serverconfig "github.com/cosmos/cosmos-sdk/server/config"
@ -444,7 +444,7 @@ func SimpleAppGenState(cdc *wire.Codec, appGenTxs []json.RawMessage) (appState j
"coins": [ "coins": [
{ {
"denom": "mycoin", "denom": "mycoin",
"amount": 9007199254740992 "amount": "9007199254740992"
} }
] ]
}] }]

View File

@ -5,7 +5,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
"github.com/cosmos/cosmos-sdk/server/mock" "github.com/cosmos/cosmos-sdk/server/mock"
"github.com/cosmos/cosmos-sdk/wire" "github.com/cosmos/cosmos-sdk/wire"

View File

@ -8,8 +8,8 @@ import (
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
tmtypes "github.com/tendermint/tendermint/types" tmtypes "github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
bam "github.com/cosmos/cosmos-sdk/baseapp" bam "github.com/cosmos/cosmos-sdk/baseapp"
gc "github.com/cosmos/cosmos-sdk/server/config" gc "github.com/cosmos/cosmos-sdk/server/config"

View File

@ -6,7 +6,7 @@ import (
"os" "os"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
) )
// SetupApp returns an application as well as a clean-up function // SetupApp returns an application as well as a clean-up function

View File

@ -1,7 +1,7 @@
package mock package mock
import ( import (
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
) )

View File

@ -5,7 +5,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
) )

View File

@ -11,7 +11,7 @@ import (
"github.com/tendermint/tendermint/node" "github.com/tendermint/tendermint/node"
pvm "github.com/tendermint/tendermint/privval" pvm "github.com/tendermint/tendermint/privval"
"github.com/tendermint/tendermint/proxy" "github.com/tendermint/tendermint/proxy"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
) )
const ( const (
@ -31,7 +31,8 @@ func StartCmd(ctx *Context, appCreator AppCreator) *cobra.Command {
return startStandAlone(ctx, appCreator) return startStandAlone(ctx, appCreator)
} }
ctx.Logger.Info("Starting ABCI with Tendermint") ctx.Logger.Info("Starting ABCI with Tendermint")
return startInProcess(ctx, appCreator) _, err := startInProcess(ctx, appCreator)
return err
}, },
} }
@ -74,12 +75,12 @@ func startStandAlone(ctx *Context, appCreator AppCreator) error {
return nil return nil
} }
func startInProcess(ctx *Context, appCreator AppCreator) error { func startInProcess(ctx *Context, appCreator AppCreator) (*node.Node, error) {
cfg := ctx.Config cfg := ctx.Config
home := cfg.RootDir home := cfg.RootDir
app, err := appCreator(home, ctx.Logger) app, err := appCreator(home, ctx.Logger)
if err != nil { if err != nil {
return err return nil, err
} }
// Create & start tendermint node // Create & start tendermint node
@ -91,15 +92,15 @@ func startInProcess(ctx *Context, appCreator AppCreator) error {
node.DefaultMetricsProvider, node.DefaultMetricsProvider,
ctx.Logger.With("module", "node")) ctx.Logger.With("module", "node"))
if err != nil { if err != nil {
return err return nil, err
} }
err = n.Start() err = n.Start()
if err != nil { if err != nil {
return err return nil, err
} }
// Trap signal, run forever. // Trap signal, run forever.
n.RunForever() n.RunForever()
return nil return n, nil
} }

View File

@ -6,14 +6,13 @@ import (
"testing" "testing"
"time" "time"
"github.com/spf13/viper"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/server/mock" "github.com/cosmos/cosmos-sdk/server/mock"
"github.com/cosmos/cosmos-sdk/wire" "github.com/cosmos/cosmos-sdk/wire"
"github.com/tendermint/tendermint/abci/server" "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/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
) )
func TestStartStandAlone(t *testing.T) { func TestStartStandAlone(t *testing.T) {
@ -45,37 +44,9 @@ func TestStartStandAlone(t *testing.T) {
svr.SetLogger(logger.With("module", "abci-server")) svr.SetLogger(logger.With("module", "abci-server"))
svr.Start() svr.Start()
timer := time.NewTimer(time.Duration(5) * time.Second) timer := time.NewTimer(time.Duration(2) * time.Second)
select { select {
case <-timer.C: case <-timer.C:
svr.Stop() svr.Stop()
} }
} }
func TestStartWithTendermint(t *testing.T) {
defer setupViper(t)()
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)).
With("module", "mock-cmd")
cfg, err := tcmd.ParseConfig()
require.Nil(t, err)
ctx := NewContext(cfg, logger)
cdc := wire.NewCodec()
appInit := AppInit{
AppGenState: mock.AppGenState,
AppGenTx: mock.AppGenTx,
}
initCmd := InitCmd(ctx, cdc, appInit)
err = initCmd.RunE(nil, nil)
require.NoError(t, err)
// set up app and start up
viper.Set(flagWithTendermint, true)
startCmd := StartCmd(ctx, mock.NewApp)
svrAddr, _, err := FreeTCPAddr()
require.NoError(t, err)
startCmd.Flags().Set(flagAddress, svrAddr) // set to a new free address
timeout := time.Duration(5) * time.Second
close(RunOrTimeout(startCmd, timeout, t))
}

View File

@ -6,12 +6,10 @@ import (
"net" "net"
"os" "os"
"testing" "testing"
"time"
"github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tendermint/tmlibs/cli" "github.com/tendermint/tendermint/libs/cli"
) )
// Get a free address for a test tendermint server // Get a free address for a test tendermint server
@ -52,25 +50,3 @@ func setupViper(t *testing.T) func() {
} }
} }
} }
// Run or Timout RunE of command passed in
func RunOrTimeout(cmd *cobra.Command, timeout time.Duration, t *testing.T) chan error {
done := make(chan error)
go func(out chan<- error) {
// this should NOT exit
err := cmd.RunE(nil, nil)
if err != nil {
out <- err
}
out <- fmt.Errorf("start died for unknown reasons")
}(done)
timer := time.NewTimer(timeout)
select {
case err := <-done:
require.NoError(t, err)
case <-timer.C:
return done
}
return done
}

View File

@ -14,7 +14,7 @@ import (
"github.com/cosmos/cosmos-sdk/wire" "github.com/cosmos/cosmos-sdk/wire"
"github.com/spf13/viper" "github.com/spf13/viper"
cfg "github.com/tendermint/tendermint/config" cfg "github.com/tendermint/tendermint/config"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
) )
var ( var (

View File

@ -15,9 +15,9 @@ import (
"github.com/cosmos/cosmos-sdk/wire" "github.com/cosmos/cosmos-sdk/wire"
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/tmlibs/cli" "github.com/tendermint/tendermint/libs/cli"
tmflags "github.com/tendermint/tmlibs/cli/flags" tmflags "github.com/tendermint/tendermint/libs/cli/flags"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
) )
// server context // server context

View File

@ -5,7 +5,7 @@ import (
"sort" "sort"
"sync" "sync"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
) )
// If value is nil but deleted is false, it means the parent doesn't have the // If value is nil but deleted is false, it means the parent doesn't have the

View File

@ -4,8 +4,8 @@ import (
"testing" "testing"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
) )
func newCacheKVStore() CacheKVStore { func newCacheKVStore() CacheKVStore {

View File

@ -2,7 +2,7 @@ package store
import ( import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
) )
type dbStoreAdapter struct { type dbStoreAdapter struct {

View File

@ -3,7 +3,7 @@ package store
import ( import (
"bytes" "bytes"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
) )
// Gets the first item. // Gets the first item.

View File

@ -5,7 +5,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
) )
func newGasKVStore() KVStore { func newGasKVStore() KVStore {

View File

@ -7,15 +7,16 @@ import (
"github.com/tendermint/go-amino" "github.com/tendermint/go-amino"
"github.com/tendermint/iavl" "github.com/tendermint/iavl"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
) )
const ( const (
defaultIAVLCacheSize = 10000 defaultIAVLCacheSize = 10000
defaultIAVLNumHistory = 1<<53 - 1 // DEPRECATED defaultIAVLNumRecent = 100
defaultIAVLStoreEvery = 10000
) )
// load the iavl store // load the iavl store
@ -25,7 +26,7 @@ func LoadIAVLStore(db dbm.DB, id CommitID) (CommitStore, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
store := newIAVLStore(tree, defaultIAVLNumHistory) store := newIAVLStore(tree, defaultIAVLNumRecent, defaultIAVLStoreEvery)
return store, nil return store, nil
} }
@ -42,17 +43,25 @@ type iavlStore struct {
tree *iavl.VersionedTree tree *iavl.VersionedTree
// How many old versions we hold onto. // How many old versions we hold onto.
// A value of 0 means keep all history. // A value of 0 means keep no recent states
numHistory int64 numRecent int64
// Distance between state-sync waypoint states to be stored
// See https://github.com/tendermint/tendermint/issues/828
// A value of 1 means store every state
// A value of 0 means store no waypoints (node cannot assist in state-sync)
// By default this value should be set the same across all nodes,
// so that nodes can know the waypoints their peers store
// TODO if set to non-default, signal to peers that the node is not suitable as a state sync source
storeEvery int64
} }
// CONTRACT: tree should be fully loaded. // CONTRACT: tree should be fully loaded.
// TODO: use more numHistory's, so the below nolint can be removed func newIAVLStore(tree *iavl.VersionedTree, numRecent int64, storeEvery int64) *iavlStore {
// nolint: unparam
func newIAVLStore(tree *iavl.VersionedTree, numHistory int64) *iavlStore {
st := &iavlStore{ st := &iavlStore{
tree: tree, tree: tree,
numHistory: numHistory, numRecent: numRecent,
storeEvery: storeEvery,
} }
return st return st
} }
@ -67,13 +76,15 @@ func (st *iavlStore) Commit() CommitID {
panic(err) panic(err)
} }
// Release an old version of history // Release an old version of history, if not a sync waypoint
if st.numHistory > 0 && (st.numHistory < st.tree.Version64()) { previous := version - 1
toRelease := version - st.numHistory if st.numRecent < previous {
err := st.tree.DeleteVersion(toRelease) toRelease := previous - st.numRecent
if err != nil { if st.storeEvery == 0 || toRelease%st.storeEvery != 0 {
// TODO: Handle with #870 err := st.tree.DeleteVersion(toRelease)
panic(err) if err != nil {
panic(err)
}
} }
} }
@ -91,6 +102,11 @@ func (st *iavlStore) LastCommitID() CommitID {
} }
} }
// VersionExists returns whether or not a given version is stored
func (st *iavlStore) VersionExists(version int64) bool {
return st.tree.VersionExists(version)
}
// Implements Store. // Implements Store.
func (st *iavlStore) GetStoreType() StoreType { func (st *iavlStore) GetStoreType() StoreType {
return sdk.StoreTypeIAVL return sdk.StoreTypeIAVL

View File

@ -1,21 +1,23 @@
package store package store
import ( import (
"fmt"
"testing" "testing"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tendermint/iavl" "github.com/tendermint/iavl"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
) )
var ( var (
cacheSize = 100 cacheSize = 100
numHistory int64 = 5 numRecent int64 = 5
storeEvery int64 = 3
) )
var ( var (
@ -45,7 +47,7 @@ func newTree(t *testing.T, db dbm.DB) (*iavl.VersionedTree, CommitID) {
func TestIAVLStoreGetSetHasDelete(t *testing.T) { func TestIAVLStoreGetSetHasDelete(t *testing.T) {
db := dbm.NewMemDB() db := dbm.NewMemDB()
tree, _ := newTree(t, db) tree, _ := newTree(t, db)
iavlStore := newIAVLStore(tree, numHistory) iavlStore := newIAVLStore(tree, numRecent, storeEvery)
key := "hello" key := "hello"
@ -70,7 +72,7 @@ func TestIAVLStoreGetSetHasDelete(t *testing.T) {
func TestIAVLIterator(t *testing.T) { func TestIAVLIterator(t *testing.T) {
db := dbm.NewMemDB() db := dbm.NewMemDB()
tree, _ := newTree(t, db) tree, _ := newTree(t, db)
iavlStore := newIAVLStore(tree, numHistory) iavlStore := newIAVLStore(tree, numRecent, storeEvery)
iter := iavlStore.Iterator([]byte("aloha"), []byte("hellz")) iter := iavlStore.Iterator([]byte("aloha"), []byte("hellz"))
expected := []string{"aloha", "hello"} expected := []string{"aloha", "hello"}
var i int var i int
@ -143,7 +145,7 @@ func TestIAVLIterator(t *testing.T) {
func TestIAVLSubspaceIterator(t *testing.T) { func TestIAVLSubspaceIterator(t *testing.T) {
db := dbm.NewMemDB() db := dbm.NewMemDB()
tree, _ := newTree(t, db) tree, _ := newTree(t, db)
iavlStore := newIAVLStore(tree, numHistory) iavlStore := newIAVLStore(tree, numRecent, storeEvery)
iavlStore.Set([]byte("test1"), []byte("test1")) iavlStore.Set([]byte("test1"), []byte("test1"))
iavlStore.Set([]byte("test2"), []byte("test2")) iavlStore.Set([]byte("test2"), []byte("test2"))
@ -202,7 +204,7 @@ func TestIAVLSubspaceIterator(t *testing.T) {
func TestIAVLReverseSubspaceIterator(t *testing.T) { func TestIAVLReverseSubspaceIterator(t *testing.T) {
db := dbm.NewMemDB() db := dbm.NewMemDB()
tree, _ := newTree(t, db) tree, _ := newTree(t, db)
iavlStore := newIAVLStore(tree, numHistory) iavlStore := newIAVLStore(tree, numRecent, storeEvery)
iavlStore.Set([]byte("test1"), []byte("test1")) iavlStore.Set([]byte("test1"), []byte("test1"))
iavlStore.Set([]byte("test2"), []byte("test2")) iavlStore.Set([]byte("test2"), []byte("test2"))
@ -258,10 +260,89 @@ func TestIAVLReverseSubspaceIterator(t *testing.T) {
require.Equal(t, len(expected), i) require.Equal(t, len(expected), i)
} }
func nextVersion(iavl *iavlStore) {
key := []byte(fmt.Sprintf("Key for tree: %d", iavl.LastCommitID().Version))
value := []byte(fmt.Sprintf("Value for tree: %d", iavl.LastCommitID().Version))
iavl.Set(key, value)
iavl.Commit()
}
func TestIAVLDefaultPruning(t *testing.T) {
//Expected stored / deleted version numbers for:
//numRecent = 5, storeEvery = 3
var states = []struct {
stored []int64
deleted []int64
}{
{[]int64{}, []int64{}},
{[]int64{1}, []int64{}},
{[]int64{1, 2}, []int64{}},
{[]int64{1, 2, 3}, []int64{}},
{[]int64{1, 2, 3, 4}, []int64{}},
{[]int64{1, 2, 3, 4, 5}, []int64{}},
{[]int64{1, 2, 3, 4, 5, 6}, []int64{}},
{[]int64{2, 3, 4, 5, 6, 7}, []int64{1}},
{[]int64{3, 4, 5, 6, 7, 8}, []int64{1, 2}},
{[]int64{3, 4, 5, 6, 7, 8, 9}, []int64{1, 2}},
{[]int64{3, 5, 6, 7, 8, 9, 10}, []int64{1, 2, 4}},
{[]int64{3, 6, 7, 8, 9, 10, 11}, []int64{1, 2, 4, 5}},
{[]int64{3, 6, 7, 8, 9, 10, 11, 12}, []int64{1, 2, 4, 5}},
{[]int64{3, 6, 8, 9, 10, 11, 12, 13}, []int64{1, 2, 4, 5, 7}},
{[]int64{3, 6, 9, 10, 11, 12, 13, 14}, []int64{1, 2, 4, 5, 7, 8}},
{[]int64{3, 6, 9, 10, 11, 12, 13, 14, 15}, []int64{1, 2, 4, 5, 7, 8}},
}
db := dbm.NewMemDB()
tree := iavl.NewVersionedTree(db, cacheSize)
iavlStore := newIAVLStore(tree, numRecent, storeEvery)
for step, state := range states {
for _, ver := range state.stored {
require.True(t, iavlStore.VersionExists(ver),
"Missing version %d with latest version %d. Should save last %d and every %d",
ver, step, numRecent, storeEvery)
}
for _, ver := range state.deleted {
require.False(t, iavlStore.VersionExists(ver),
"Unpruned version %d with latest version %d. Should prune all but last %d and every %d",
ver, step, numRecent, storeEvery)
}
nextVersion(iavlStore)
}
}
func TestIAVLNoPrune(t *testing.T) {
db := dbm.NewMemDB()
tree := iavl.NewVersionedTree(db, cacheSize)
iavlStore := newIAVLStore(tree, numRecent, int64(1))
nextVersion(iavlStore)
for i := 1; i < 100; i++ {
for j := 1; j <= i; j++ {
require.True(t, iavlStore.VersionExists(int64(j)),
"Missing version %d with latest version %d. Should be storing all versions",
j, i)
}
nextVersion(iavlStore)
}
}
func TestIAVLPruneEverything(t *testing.T) {
db := dbm.NewMemDB()
tree := iavl.NewVersionedTree(db, cacheSize)
iavlStore := newIAVLStore(tree, int64(0), int64(0))
nextVersion(iavlStore)
for i := 1; i < 100; i++ {
for j := 1; j < i; j++ {
require.False(t, iavlStore.VersionExists(int64(j)),
"Unpruned version %d with latest version %d. Should prune all old versions",
j, i)
}
require.True(t, iavlStore.VersionExists(int64(i)),
"Missing current version on step %d, should not prune current state tree",
i)
nextVersion(iavlStore)
}
}
func TestIAVLStoreQuery(t *testing.T) { func TestIAVLStoreQuery(t *testing.T) {
db := dbm.NewMemDB() db := dbm.NewMemDB()
tree := iavl.NewVersionedTree(db, cacheSize) tree := iavl.NewVersionedTree(db, cacheSize)
iavlStore := newIAVLStore(tree, numHistory) iavlStore := newIAVLStore(tree, numRecent, storeEvery)
k1, v1 := []byte("key1"), []byte("val1") k1, v1 := []byte("key1"), []byte("val1")
k2, v2 := []byte("key2"), []byte("val2") k2, v2 := []byte("key2"), []byte("val2")

View File

@ -3,8 +3,8 @@ package store
import ( import (
"bytes" "bytes"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
) )
// Iterates over iterKVCache items. // Iterates over iterKVCache items.

View File

@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tendermint/iavl" "github.com/tendermint/iavl"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
) )
@ -66,7 +66,7 @@ func testPrefixStore(t *testing.T, baseStore KVStore, prefix []byte) {
func TestIAVLStorePrefix(t *testing.T) { func TestIAVLStorePrefix(t *testing.T) {
db := dbm.NewMemDB() db := dbm.NewMemDB()
tree := iavl.NewVersionedTree(db, cacheSize) tree := iavl.NewVersionedTree(db, cacheSize)
iavlStore := newIAVLStore(tree, numHistory) iavlStore := newIAVLStore(tree, numRecent, storeEvery)
testPrefixStore(t, iavlStore, []byte("test")) testPrefixStore(t, iavlStore, []byte("test"))
} }

View File

@ -7,8 +7,8 @@ import (
"golang.org/x/crypto/ripemd160" "golang.org/x/crypto/ripemd160"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/merkle" "github.com/tendermint/tendermint/crypto/merkle"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
) )

View File

@ -5,8 +5,8 @@ import (
"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/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/merkle" "github.com/tendermint/tendermint/crypto/merkle"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
) )

View File

@ -5,7 +5,7 @@ import (
"testing" "testing"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
) )
// Execute the command, return stdout, logging stdout/err to t. // Execute the command, return stdout, logging stdout/err to t.

View File

@ -6,8 +6,8 @@ import (
"fmt" "fmt"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tmlibs/bech32" "github.com/tendermint/tendermint/libs/bech32"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
) )
//Address is a go crypto-style Address //Address is a go crypto-style Address

View File

@ -7,7 +7,7 @@ import (
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
) )
/* /*

View File

@ -5,8 +5,8 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
"github.com/cosmos/cosmos-sdk/store" "github.com/cosmos/cosmos-sdk/store"
"github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types"

View File

@ -3,7 +3,7 @@ package types
import ( import (
"fmt" "fmt"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
) )

View File

@ -6,8 +6,8 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"

View File

@ -4,8 +4,8 @@ import (
"fmt" "fmt"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
) )
// NOTE: These are implemented in cosmos-sdk/store. // NOTE: These are implemented in cosmos-sdk/store.

View File

@ -1,7 +1,7 @@
package types package types
import ( import (
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tendermint/libs/common"
) )
// Type synonym for convenience // Type synonym for convenience

View File

@ -7,7 +7,7 @@ import (
"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"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
wire "github.com/cosmos/cosmos-sdk/wire" wire "github.com/cosmos/cosmos-sdk/wire"

View File

@ -6,7 +6,7 @@ import (
"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/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
) )

View File

@ -6,7 +6,7 @@ import (
"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/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
wire "github.com/cosmos/cosmos-sdk/wire" wire "github.com/cosmos/cosmos-sdk/wire"

View File

@ -6,8 +6,8 @@ import (
"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/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
"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"

View File

@ -5,8 +5,8 @@ import (
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
bam "github.com/cosmos/cosmos-sdk/baseapp" bam "github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"

View File

@ -7,8 +7,8 @@ import (
"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/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
"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"

View File

@ -7,7 +7,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"

View File

@ -7,8 +7,8 @@ import (
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
"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"

View File

@ -5,7 +5,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/tendermint/tmlibs/cli" "github.com/tendermint/tendermint/libs/cli"
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"

View File

@ -9,8 +9,8 @@ import (
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
"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"

View File

@ -5,7 +5,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/tendermint/tmlibs/cli" "github.com/tendermint/tendermint/libs/cli"
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"

View File

@ -10,8 +10,8 @@ import (
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
dbm "github.com/tendermint/tmlibs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tendermint/libs/log"
"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"