Skip to content

Commit 6967905

Browse files
authored
Merge pull request #1238 from cosmos/release/v0.19.0
Release/v0.19.0
2 parents 35a3c14 + 65786e4 commit 6967905

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+3416
-2112
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
<!-- Thanks for filing a PR! Before hitting the button, please check the following items.-->
1+
<!-- < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < ☺
2+
v ✰ Thanks for creating a PR! ✰
3+
v Before smashing the submit button please review the checkboxes.
4+
v If a checkbox is n/a - please still include it but + a little note why
5+
☺ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -->
26

37
* [ ] Updated all relevant documentation in docs
48
* [ ] Updated all code comments where relevant
59
* [ ] Wrote tests
610
* [ ] Updated CHANGELOG.md
7-
* [ ] Updated Basecoin / other examples
8-
* [ ] Squashed related commits and prefixed with PR number per [coding standards](https://github.com/tendermint/coding/blob/master/README.md#merging-a-pr)
11+
* [ ] Updated Gaia/Examples
12+
* [ ] Squashed all commits, uses message "Merge pull request #XYZ: [title]" ([coding standards](https://github.com/tendermint/coding/blob/master/README.md#merging-a-pr))

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ docs/_build
1414
# Data - ideally these don't exist
1515
examples/basecoin/app/data
1616
baseapp/data/*
17+
client/lcd/keys/*
1718

1819
# Testing
1920
coverage.txt
@@ -26,4 +27,4 @@ profile.out
2627
vagrant
2728

2829
# Graphviz
29-
dependency-graph.png
30+
dependency-graph.png

CHANGELOG.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
11
# Changelog
22

3+
## 0.19.0
4+
5+
*June 13, 2018*
6+
37
BREAKING CHANGES
48
* msg.GetSignBytes() now returns bech32-encoded addresses in all cases
9+
* [lcd] REST end-points now include gas
510

611
FEATURES
12+
* [x/auth] Added AccountNumbers to BaseAccount and StdTxs to allow for replay protection with account pruning
713

814
IMPROVEMENTS
915
* export command now writes current validator set for Tendermint
1016
* [tests] Application module tests now use a mock application
17+
* [gaiacli] Fix error message when account isn't found when running gaiacli account
18+
* [lcd] refactored to eliminate use of global variables, and interdependent tests
19+
* [x/stake] More stake tests added to test ByPower index
1120

1221
FIXES
22+
* Fixes consensus fault on testnet - see postmortem [here](https://github.com/cosmos/cosmos-sdk/issues/1197#issuecomment-396823021)
23+
* [x/stake] bonded inflation removed, non-bonded inflation partially implemented
1324
* [lcd] Switch to bech32 for addresses on all human readable inputs and outputs
25+
* [lcd] fixed tx indexing/querying
1426
* [cli] Added `--gas` flag to specify transaction gas limit
27+
* [gaia] Registered slashing message handler
28+
* [x/slashing] Set signInfo.StartHeight correctly for newly bonded validators
1529

1630
## 0.18.0
1731

@@ -81,6 +95,25 @@ BUG FIXES
8195
* [gaiacli] Fix error message when account isn't found when running gaiacli account
8296

8397

98+
## 0.17.5
99+
100+
*June 5, 2018*
101+
102+
Update to Tendermint v0.19.9 (Fix evidence reactor, mempool deadlock, WAL panic,
103+
memory leak)
104+
105+
## 0.17.4
106+
107+
*May 31, 2018*
108+
109+
Update to Tendermint v0.19.7 (WAL fixes and more)
110+
111+
## 0.17.3
112+
113+
*May 29, 2018*
114+
115+
Update to Tendermint v0.19.6 (fix fast-sync halt)
116+
84117
## 0.17.5
85118

86119
*June 5, 2018*

Gopkg.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ install_examples:
4646
go install $(BUILD_FLAGS) ./examples/democoin/cmd/democoind
4747
go install $(BUILD_FLAGS) ./examples/democoin/cmd/democli
4848

49+
install_debug:
50+
go install $(BUILD_FLAGS) ./cmd/gaia/cmd/gaiadebug
51+
4952
dist:
5053
@bash publish/dist.sh
5154
@bash publish/publish.sh
@@ -92,6 +95,9 @@ test_cli:
9295
test_unit:
9396
@go test $(PACKAGES_NOCLITEST)
9497

98+
test_race:
99+
@go test -race $(PACKAGES_NOCLITEST)
100+
95101
test_cover:
96102
@bash tests/test_cover.sh
97103

@@ -154,4 +160,4 @@ remotenet-status:
154160
# To avoid unintended conflicts with file names, always add to .PHONY
155161
# unless there is a reason not to.
156162
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
157-
.PHONY: build build_examples install install_examples dist check_tools get_tools get_vendor_deps draw_deps test test_cli test_unit test_cover test_lint benchmark devdoc_init devdoc devdoc_save devdoc_update remotenet-start remotenet-stop remotenet-status
163+
.PHONY: build build_examples install install_examples install_debug dist check_tools get_tools get_vendor_deps draw_deps test test_cli test_unit test_cover test_lint benchmark devdoc_init devdoc devdoc_save devdoc_update remotenet-start remotenet-stop remotenet-status

client/context/helpers.go

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,15 @@ func (ctx CoreContext) SignAndBuild(name, passphrase string, msg sdk.Msg, cdc *w
109109
if chainID == "" {
110110
return nil, errors.Errorf("Chain ID required but not specified")
111111
}
112+
accnum := ctx.AccountNumber
112113
sequence := ctx.Sequence
114+
113115
signMsg := auth.StdSignMsg{
114-
ChainID: chainID,
115-
Sequences: []int64{sequence},
116-
Msg: msg,
117-
Fee: auth.NewStdFee(ctx.Gas, sdk.Coin{}), // TODO run simulate to estimate gas?
116+
ChainID: chainID,
117+
AccountNumbers: []int64{accnum},
118+
Sequences: []int64{sequence},
119+
Msg: msg,
120+
Fee: auth.NewStdFee(ctx.Gas, sdk.Coin{}), // TODO run simulate to estimate gas?
118121
}
119122

120123
keybase, err := keys.GetKeyBase()
@@ -130,9 +133,10 @@ func (ctx CoreContext) SignAndBuild(name, passphrase string, msg sdk.Msg, cdc *w
130133
return nil, err
131134
}
132135
sigs := []auth.StdSignature{{
133-
PubKey: pubkey,
134-
Signature: sig,
135-
Sequence: sequence,
136+
PubKey: pubkey,
137+
Signature: sig,
138+
AccountNumber: accnum,
139+
Sequence: sequence,
136140
}}
137141

138142
// marshal bytes
@@ -144,6 +148,10 @@ func (ctx CoreContext) SignAndBuild(name, passphrase string, msg sdk.Msg, cdc *w
144148
// sign and build the transaction from the msg
145149
func (ctx CoreContext) EnsureSignBuildBroadcast(name string, msg sdk.Msg, cdc *wire.Codec) (res *ctypes.ResultBroadcastTxCommit, err error) {
146150

151+
ctx, err = EnsureAccountNumber(ctx)
152+
if err != nil {
153+
return nil, err
154+
}
147155
// default to next sequence number if none provided
148156
ctx, err = EnsureSequence(ctx)
149157
if err != nil {
@@ -163,13 +171,37 @@ func (ctx CoreContext) EnsureSignBuildBroadcast(name string, msg sdk.Msg, cdc *w
163171
return ctx.BroadcastTx(txBytes)
164172
}
165173

174+
// get the next sequence for the account address
175+
func (ctx CoreContext) GetAccountNumber(address []byte) (int64, error) {
176+
if ctx.Decoder == nil {
177+
return 0, errors.New("AccountDecoder required but not provided")
178+
}
179+
180+
res, err := ctx.Query(auth.AddressStoreKey(address), ctx.AccountStore)
181+
if err != nil {
182+
return 0, err
183+
}
184+
185+
if len(res) == 0 {
186+
fmt.Printf("No account found. Returning 0.\n")
187+
return 0, err
188+
}
189+
190+
account, err := ctx.Decoder(res)
191+
if err != nil {
192+
panic(err)
193+
}
194+
195+
return account.GetAccountNumber(), nil
196+
}
197+
166198
// get the next sequence for the account address
167199
func (ctx CoreContext) NextSequence(address []byte) (int64, error) {
168200
if ctx.Decoder == nil {
169201
return 0, errors.New("AccountDecoder required but not provided")
170202
}
171203

172-
res, err := ctx.Query(address, ctx.AccountStore)
204+
res, err := ctx.Query(auth.AddressStoreKey(address), ctx.AccountStore)
173205
if err != nil {
174206
return 0, err
175207
}

client/context/types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ type CoreContext struct {
1414
TrustNode bool
1515
NodeURI string
1616
FromAddressName string
17+
AccountNumber int64
1718
Sequence int64
1819
Client rpcclient.Client
1920
Decoder auth.AccountDecoder
@@ -57,6 +58,12 @@ func (c CoreContext) WithFromAddressName(fromAddressName string) CoreContext {
5758
return c
5859
}
5960

61+
// WithSequence - return a copy of the context with an account number
62+
func (c CoreContext) WithAccountNumber(accnum int64) CoreContext {
63+
c.AccountNumber = accnum
64+
return c
65+
}
66+
6067
// WithSequence - return a copy of the context with an updated sequence number
6168
func (c CoreContext) WithSequence(sequence int64) CoreContext {
6269
c.Sequence = sequence

client/context/viper.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func NewCoreContextFromViper() CoreContext {
3434
TrustNode: viper.GetBool(client.FlagTrustNode),
3535
FromAddressName: viper.GetString(client.FlagName),
3636
NodeURI: nodeURI,
37+
AccountNumber: viper.GetInt64(client.FlagAccountNumber),
3738
Sequence: viper.GetInt64(client.FlagSequence),
3839
Client: rpc,
3940
Decoder: nil,
@@ -54,6 +55,25 @@ func defaultChainID() (string, error) {
5455
return doc.ChainID, nil
5556
}
5657

58+
// EnsureSequence - automatically set sequence number if none provided
59+
func EnsureAccountNumber(ctx CoreContext) (CoreContext, error) {
60+
// Should be viper.IsSet, but this does not work - https://github.com/spf13/viper/pull/331
61+
if viper.GetInt64(client.FlagAccountNumber) != 0 {
62+
return ctx, nil
63+
}
64+
from, err := ctx.GetFromAddress()
65+
if err != nil {
66+
return ctx, err
67+
}
68+
accnum, err := ctx.GetAccountNumber(from)
69+
if err != nil {
70+
return ctx, err
71+
}
72+
fmt.Printf("Defaulting to account number: %d\n", accnum)
73+
ctx = ctx.WithAccountNumber(accnum)
74+
return ctx, nil
75+
}
76+
5777
// EnsureSequence - automatically set sequence number if none provided
5878
func EnsureSequence(ctx CoreContext) (CoreContext, error) {
5979
// Should be viper.IsSet, but this does not work - https://github.com/spf13/viper/pull/331

client/flags.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import "github.com/spf13/cobra"
44

55
// nolint
66
const (
7-
FlagChainID = "chain-id"
8-
FlagNode = "node"
9-
FlagHeight = "height"
10-
FlagGas = "gas"
11-
FlagTrustNode = "trust-node"
12-
FlagName = "name"
13-
FlagSequence = "sequence"
14-
FlagFee = "fee"
7+
FlagChainID = "chain-id"
8+
FlagNode = "node"
9+
FlagHeight = "height"
10+
FlagGas = "gas"
11+
FlagTrustNode = "trust-node"
12+
FlagName = "name"
13+
FlagAccountNumber = "account-number"
14+
FlagSequence = "sequence"
15+
FlagFee = "fee"
1516
)
1617

1718
// LineBreak can be included in a command list to provide a blank line
@@ -26,7 +27,6 @@ func GetCommands(cmds ...*cobra.Command) []*cobra.Command {
2627
c.Flags().String(FlagChainID, "", "Chain ID of tendermint node")
2728
c.Flags().String(FlagNode, "tcp://localhost:46657", "<host>:<port> to tendermint rpc interface for this chain")
2829
c.Flags().Int64(FlagHeight, 0, "block height to query, omit to get most recent provable block")
29-
c.Flags().Int64(FlagGas, 200000, "gas limit to set per-transaction")
3030
}
3131
return cmds
3232
}
@@ -35,6 +35,7 @@ func GetCommands(cmds ...*cobra.Command) []*cobra.Command {
3535
func PostCommands(cmds ...*cobra.Command) []*cobra.Command {
3636
for _, c := range cmds {
3737
c.Flags().String(FlagName, "", "Name of private key with which to sign")
38+
c.Flags().Int64(FlagAccountNumber, 0, "AccountNumber number to sign the tx")
3839
c.Flags().Int64(FlagSequence, 0, "Sequence number to sign the tx")
3940
c.Flags().String(FlagFee, "", "Fee to pay along with transaction")
4041
c.Flags().String(FlagChainID, "", "Chain ID of tendermint node")

client/keys/add.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,6 @@ func runAddCmd(cmd *cobra.Command, args []string) error {
102102
return nil
103103
}
104104

105-
// addOutput lets us json format the data
106-
type addOutput struct {
107-
Key keys.Info `json:"key"`
108-
Seed string `json:"seed"`
109-
}
110-
111105
func printCreate(info keys.Info, seed string) {
112106
output := viper.Get(cli.OutputFlag)
113107
switch output {
@@ -121,7 +115,10 @@ func printCreate(info keys.Info, seed string) {
121115
fmt.Println(seed)
122116
}
123117
case "json":
124-
out := addOutput{Key: info}
118+
out, err := Bech32KeyOutput(info)
119+
if err != nil {
120+
panic(err)
121+
}
125122
if !viper.GetBool(flagNoBackup) {
126123
out.Seed = seed
127124
}

client/keys/list.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"encoding/json"
55
"net/http"
66

7-
sdk "github.com/cosmos/cosmos-sdk/types"
87
"github.com/spf13/cobra"
98
)
109

@@ -54,9 +53,11 @@ func QueryKeysRequestHandler(w http.ResponseWriter, r *http.Request) {
5453
w.Write([]byte("[]"))
5554
return
5655
}
57-
keysOutput := make([]KeyOutput, len(infos))
58-
for i, info := range infos {
59-
keysOutput[i] = KeyOutput{Name: info.Name, Address: sdk.Address(info.PubKey.Address().Bytes())}
56+
keysOutput, err := Bech32KeysOutput(infos)
57+
if err != nil {
58+
w.WriteHeader(500)
59+
w.Write([]byte(err.Error()))
60+
return
6061
}
6162
output, err := json.MarshalIndent(keysOutput, "", " ")
6263
if err != nil {

0 commit comments

Comments
 (0)