Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
fedekunze committed Feb 17, 2020
2 parents b85c8f5 + 235aa6c commit d8a693d
Show file tree
Hide file tree
Showing 166 changed files with 15,138 additions and 3,018 deletions.
1 change: 1 addition & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ ignore:
- "docs"
- "*.md"
- "*.rst"
- "**/*.pb.go"
- "x/**/test_common.go"
- "scripts/"
- "contrib"
5 changes: 5 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ issues:
- text: "ST1003:"
linters:
- stylecheck
# FIXME: Disabled until golangci-lint updates stylecheck with this fix:
# https://github.com/dominikh/go-tools/issues/389
- text: "ST1016:"
linters:
- stylecheck

linters-settings:
dogsled:
Expand Down
73 changes: 68 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,28 @@ Ref: https://keepachangelog.com/en/1.0.0/

* (modules) [\#5572](https://github.com/cosmos/cosmos-sdk/pull/5572) The `/bank/balances/{address}` endpoint now returns all account
balances or a single balance by denom when the `denom` query parameter is present.
* (client) [\#5640](https://github.com/cosmos/cosmos-sdk/pull/5640) The rest server endpoint `/swagger-ui/` is replaced by
´/´.

### API Breaking Changes

* (x/params) [\#5619](https://github.com/cosmos/cosmos-sdk/pull/5619) The `x/params` keeper now accepts a `codec.Marshaller` instead of
a reference to an amino codec. Amino is still used for JSON serialization.
* (types) [\#5579](https://github.com/cosmos/cosmos-sdk/pull/5579) The `keepRecent` field has been removed from the `PruningOptions` type.
The `PruningOptions` type now only includes fields `KeepEvery` and `SnapshotEvery`, where `KeepEvery`
determines which committed heights are flushed to disk and `SnapshotEvery` determines which of these
heights are kept after pruning. The `IsValid` method should be called whenever using these options. Methods
`SnapshotVersion` and `FlushVersion` accept a version arugment and determine if the version should be
flushed to disk or kept as a snapshot. Note, `KeepRecent` is automatically inferred from the options
and provided directly the IAVL store.
* (modules) [\#5555](https://github.com/cosmos/cosmos-sdk/pull/5555) Move x/auth/client/utils/ types and functions to x/auth/client/.
* (modules) [\#5572](https://github.com/cosmos/cosmos-sdk/pull/5572) Move account balance logic and APIs from `x/auth` to `x/bank`.

### Bug Fixes

* (x/bank) [\#5531](https://github.com/cosmos/cosmos-sdk/issues/5531) Added missing amount event to MsgMultiSend, emitted for each output.
* (client) [\#5618](https://github.com/cosmos/cosmos-sdk/pull/5618) Fix crash on the client when the verifier is not set.
* (x/distribution) [\#5620](https://github.com/cosmos/cosmos-sdk/pull/5620) Fix nil pointer deref in distribution tax/rewward validation helpers.
* (genesis) [\#5086](https://github.com/cosmos/cosmos-sdk/issues/5086) Ensure `gentxs` are always an empty array instead of `nil`

### State Machine Breaking

Expand All @@ -59,12 +72,26 @@ balances or a single balance by denom when the `denom` query parameter is presen
* Callers to `NewBaseVestingAccount` are responsible for verifying account balance in relation to
the original vesting amount.
* The `SendKeeper` and `ViewKeeper` interfaces in `x/bank` have been modified to account for changes.
* (staking) [\#5600](https://github.com/cosmos/cosmos-sdk/pull/5600) Migrate the `x/staking` module to use Protocol Buffer for state
serialization instead of Amino. The exact codec used is `codec.HybridCodec` which utilizes Protobuf for binary encoding and Amino
for JSON encoding.
* `BondStatus` is now of type `int32` instead of `byte`.
* Types of `int16` in the `Params` type are now of type `int32`.
* Every reference of `crypto.Pubkey` in context of a `Validator` is now of type string. `GetPubKeyFromBech32` must be used to get the `crypto.Pubkey`.
* The `Keeper` constructor now takes a `codec.Marshaler` instead of a concrete Amino codec. This exact type
provided is specified by `ModuleCdc`.
* (distr) [\#5610](https://github.com/cosmos/cosmos-sdk/pull/5610) Migrate the `x/distribution` module to use Protocol Buffer for state
serialization instead of Amino. The exact codec used is `codec.HybridCodec` which utilizes Protobuf for binary encoding and Amino
for JSON encoding.
* `ValidatorHistoricalRewards.ReferenceCount` is now of types `uint32` instead of `uint16`.
* `ValidatorSlashEvents` is now a struct with `slashevents`.
* `ValidatorOutstandingRewards` is now a struct with `rewards`.
* `ValidatorAccumulatedCommission` is now a struct with `commission`.
* The `Keeper` constructor now takes a `codec.Marshaler` instead of a concrete Amino codec. This exact type
provided is specified by `ModuleCdc`.

### Improvements

* (modules) [\#5597](https://github.com/cosmos/cosmos-sdk/pull/5597) Add `amount` event attribute to the `complete_unbonding`
and `complete_redelegation` events that reflect the total balances of the completed unbondings and redelegations
respectively.
* (types) [\#5581](https://github.com/cosmos/cosmos-sdk/pull/5581) Add convenience functions {,Must}Bech32ifyAddressBytes.
* (staking) [\#5584](https://github.com/cosmos/cosmos-sdk/pull/5584) Add util function `ToTmValidator` that converts a `staking.Validator` type to `*tmtypes.Validator`.
* (client) [\#5585](https://github.com/cosmos/cosmos-sdk/pull/5585) IBC additions:
Expand All @@ -73,6 +100,27 @@ respectively.
* (types) [\#5585](https://github.com/cosmos/cosmos-sdk/pull/5585) IBC additions:
* `Coin` denomination max lenght has been increased to 32.
* Added `CapabilityKey` alias for `StoreKey` to match IBC spec.
* (rest) [\#5648](https://github.com/cosmos/cosmos-sdk/pull/5648) Enhance /txs usability:
* Add `tx.minheight` key to filter transaction with an inclusive minimum block height
* Add `tx.maxheight` key to filter transaction with an inclusive maximum block height

## [v0.38.1] - 2020-02-11

### Improvements

* (modules) [\#5597](https://github.com/cosmos/cosmos-sdk/pull/5597) Add `amount` event attribute to the `complete_unbonding`
and `complete_redelegation` events that reflect the total balances of the completed unbondings and redelegations
respectively.

### Bug Fixes

* (types) [\#5579](https://github.com/cosmos/cosmos-sdk/pull/5579) The IAVL `Store#Commit` method has been refactored to
delete a flushed version if it is not a snapshot version. The root multi-store now keeps track of `commitInfo` instead
of `types.CommitID`. During `Commit` of the root multi-store, `lastCommitInfo` is updated from the saved state
and is only flushed to disk if it is a snapshot version. During `Query` of the root multi-store, if the request height
is the latest height, we'll use the store's `lastCommitInfo`. Otherwise, we fetch `commitInfo` from disk.
* (x/bank) [\#5531](https://github.com/cosmos/cosmos-sdk/issues/5531) Added missing amount event to MsgMultiSend, emitted for each output.
* (x/gov) [\#5622](https://github.com/cosmos/cosmos-sdk/pull/5622) Track any events emitted from a proposal's handler upon successful execution.

## [v0.38.0] - 2020-01-23

Expand Down Expand Up @@ -308,6 +356,19 @@ to detail this new feature and how state transitions occur.
* (x/gov) [\#5107](https://github.com/cosmos/cosmos-sdk/pull/5107) Sum validator operator's all voting power when tally votes
* (rest) [\#5212](https://github.com/cosmos/cosmos-sdk/issues/5212) Fix pagination in the `/gov/proposals` handler.

## [v0.37.7] - 2020-02-10

### Improvements

* (modules) [\#5597](https://github.com/cosmos/cosmos-sdk/pull/5597) Add `amount` event attribute to the `complete_unbonding`
and `complete_redelegation` events that reflect the total balances of the completed unbondings and redelegations
respectively.

### Bug Fixes

* (x/gov) [\#5622](https://github.com/cosmos/cosmos-sdk/pull/5622) Track any events emitted from a proposal's handler upon successful execution.
* (x/bank) [\#5531](https://github.com/cosmos/cosmos-sdk/issues/5531) Added missing amount event to MsgMultiSend, emitted for each output.

## [v0.37.6] - 2020-01-21

### Improvements
Expand Down Expand Up @@ -2899,8 +2960,10 @@ BUG FIXES:

<!-- Release links -->

[Unreleased]: https://github.com/cosmos/cosmos-sdk/compare/v0.38.0...HEAD
[Unreleased]: https://github.com/cosmos/cosmos-sdk/compare/v0.38.1...HEAD
[v0.38.1]: https://github.com/cosmos/cosmos-sdk/releases/tag/v0.38.1
[v0.38.0]: https://github.com/cosmos/cosmos-sdk/releases/tag/v0.38.0
[v0.37.7]: https://github.com/cosmos/cosmos-sdk/releases/tag/v0.37.7
[v0.37.6]: https://github.com/cosmos/cosmos-sdk/releases/tag/v0.37.6
[v0.37.5]: https://github.com/cosmos/cosmos-sdk/releases/tag/v0.37.5
[v0.37.4]: https://github.com/cosmos/cosmos-sdk/releases/tag/v0.37.4
Expand Down
27 changes: 24 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ benchmark:
### Linting ###
###############################################################################

lint: golangci-lint
$(BINDIR)/golangci-lint run
lint:
golangci-lint run
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s
go mod verify
.PHONY: lint
Expand Down Expand Up @@ -238,4 +238,25 @@ proto-lint:
proto-check-breaking:
@buf check breaking --against-input '.git#branch=master'

.PHONY: proto-all proto-gen proto-lint proto-check-breaking
# Origin
# TODO: Update to the version of Tendermint that is being used in go.mod
version_branch = v0.33.0
tendermint = https://raw.githubusercontent.com/tendermint/tendermint/$(version_branch)

# Outputs
tmkv = third_party/proto/tendermint/libs/kv/types.proto
tmmerkle = third_party/proto/tendermint/crypto/merkle/merkle.proto
tmabci = third_party/proto/tendermint/abci/types/types.proto

# You *only* need to run this to rebuild protobufs from the tendermint source
proto-update-tendermint:
@curl $(tendermint)/abci/types/types.proto > $(tmabci)
sed -i '' '8,9 s|github.com/tendermint|third_party/proto|g' $(tmabci)
sed -i '' '7 s|github.com/gogo/protobuf|third_party/proto|' $(tmabci)
@curl $(tendermint)/libs/kv/types.proto > $(tmkv)
sed -i '' 's|github.com/gogo/protobuf|third_party/proto|' $(tmkv)
@curl $(tendermint)/crypto/merkle/merkle.proto > $(tmmerkle)
sed -i '' '7 s|github.com/gogo/protobuf|third_party/proto|' $(tmmerkle)


.PHONY: proto-all proto-gen proto-lint proto-check-breaking proto-update-tendermint
86 changes: 84 additions & 2 deletions baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestMountStores(t *testing.T) {
// Test that LoadLatestVersion actually does.
func TestLoadVersion(t *testing.T) {
logger := defaultLogger()
pruningOpt := SetPruning(store.PruneSyncable)
pruningOpt := SetPruning(store.PruneNothing)
db := dbm.NewMemDB()
name := t.Name()
app := NewBaseApp(name, logger, db, nil, pruningOpt)
Expand Down Expand Up @@ -293,7 +293,7 @@ func TestAppVersionSetterGetter(t *testing.T) {

func TestLoadVersionInvalid(t *testing.T) {
logger := log.NewNopLogger()
pruningOpt := SetPruning(store.PruneSyncable)
pruningOpt := SetPruning(store.PruneNothing)
db := dbm.NewMemDB()
name := t.Name()
app := NewBaseApp(name, logger, db, nil, pruningOpt)
Expand Down Expand Up @@ -326,6 +326,88 @@ func TestLoadVersionInvalid(t *testing.T) {
require.Error(t, err)
}

func TestLoadVersionPruning(t *testing.T) {
logger := log.NewNopLogger()
pruningOptions := store.PruningOptions{
KeepEvery: 2,
SnapshotEvery: 6,
}
pruningOpt := SetPruning(pruningOptions)
db := dbm.NewMemDB()
name := t.Name()
app := NewBaseApp(name, logger, db, nil, pruningOpt)

// make a cap key and mount the store
capKey := sdk.NewKVStoreKey(MainStoreKey)
app.MountStores(capKey)
err := app.LoadLatestVersion(capKey) // needed to make stores non-nil
require.Nil(t, err)

emptyCommitID := sdk.CommitID{}

// fresh store has zero/empty last commit
lastHeight := app.LastBlockHeight()
lastID := app.LastCommitID()
require.Equal(t, int64(0), lastHeight)
require.Equal(t, emptyCommitID, lastID)

// execute a block
header := abci.Header{Height: 1}
app.BeginBlock(abci.RequestBeginBlock{Header: header})
res := app.Commit()

// execute a block, collect commit ID
header = abci.Header{Height: 2}
app.BeginBlock(abci.RequestBeginBlock{Header: header})
res = app.Commit()
commitID2 := sdk.CommitID{Version: 2, Hash: res.Data}

// execute a block
header = abci.Header{Height: 3}
app.BeginBlock(abci.RequestBeginBlock{Header: header})
res = app.Commit()
commitID3 := sdk.CommitID{Version: 3, Hash: res.Data}

// reload with LoadLatestVersion, check it loads last flushed version
app = NewBaseApp(name, logger, db, nil, pruningOpt)
app.MountStores(capKey)
err = app.LoadLatestVersion(capKey)
require.Nil(t, err)
testLoadVersionHelper(t, app, int64(2), commitID2)

// re-execute block 3 and check it is same CommitID
header = abci.Header{Height: 3}
app.BeginBlock(abci.RequestBeginBlock{Header: header})
res = app.Commit()
recommitID3 := sdk.CommitID{Version: 3, Hash: res.Data}
require.Equal(t, commitID3, recommitID3, "Commits of identical blocks not equal after reload")

// execute a block, collect commit ID
header = abci.Header{Height: 4}
app.BeginBlock(abci.RequestBeginBlock{Header: header})
res = app.Commit()
commitID4 := sdk.CommitID{Version: 4, Hash: res.Data}

// execute a block
header = abci.Header{Height: 5}
app.BeginBlock(abci.RequestBeginBlock{Header: header})
res = app.Commit()

// reload with LoadLatestVersion, check it loads last flushed version
app = NewBaseApp(name, logger, db, nil, pruningOpt)
app.MountStores(capKey)
err = app.LoadLatestVersion(capKey)
require.Nil(t, err)
testLoadVersionHelper(t, app, int64(4), commitID4)

// reload with LoadVersion of previous flushed version
// and check it fails since previous flush should be pruned
app = NewBaseApp(name, logger, db, nil, pruningOpt)
app.MountStores(capKey)
err = app.LoadVersion(2, capKey)
require.NotNil(t, err)
}

func testLoadVersionHelper(t *testing.T, app *BaseApp, expectedHeight int64, expectedID sdk.CommitID) {
lastHeight := app.LastBlockHeight()
lastID := app.LastCommitID()
Expand Down
3 changes: 3 additions & 0 deletions client/context/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ func (ctx CLIContext) query(path string, key tmbytes.HexBytes) ([]byte, int64, e

// Verify verifies the consensus proof at given height.
func (ctx CLIContext) Verify(height int64) (tmtypes.SignedHeader, error) {
if ctx.Verifier == nil {
return tmtypes.SignedHeader{}, fmt.Errorf("missing valid certifier to verify data from distrusted node")
}
check, err := tmliteProxy.GetCertifiedCommit(height, ctx.Client, ctx.Verifier)
switch {
case tmliteErr.IsErrCommitNotFound(err):
Expand Down
2 changes: 1 addition & 1 deletion client/lcd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,5 @@ func (rs *RestServer) registerSwaggerUI() {
panic(err)
}
staticServer := http.FileServer(statikFS)
rs.Mux.PathPrefix("/swagger-ui/").Handler(http.StripPrefix("/swagger-ui/", staticServer))
rs.Mux.PathPrefix("/").Handler(staticServer)
}
14 changes: 12 additions & 2 deletions client/lcd/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ tags:
description: Query app version
schemes:
- https
host: stargate.cosmos.network
host: api.cosmos.network
securityDefinitions:
kms:
type: basic
Expand All @@ -42,7 +42,7 @@ paths:
description: Information about the connected node
summary: The properties of the connected node
tags:
- Tendermint RPC
- Gaia REST
produces:
- application/json
responses:
Expand Down Expand Up @@ -270,6 +270,16 @@ paths:
description: Maximum number of items per page
type: integer
x-example: 1
- in: query
name: tx.minheight
type: integer
description: "transactions on blocks with height greater or equal this value"
x-example: 25
- in: query
name: tx.maxheight
type: integer
description: "transactions on blocks with height less than or equal this value"
x-example: 800000
responses:
200:
description: All txs matching the provided events
Expand Down
8 changes: 4 additions & 4 deletions codec/amino.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func RegisterEvidences(cdc *Codec) {
// MarshalJSONIndent provides a utility for indented JSON encoding of an object
// via an Amino codec. It returns an error if it cannot serialize or indent as
// JSON.
func MarshalJSONIndent(cdc *Codec, obj interface{}) ([]byte, error) {
bz, err := cdc.MarshalJSON(obj)
func MarshalJSONIndent(m JSONMarshaler, obj interface{}) ([]byte, error) {
bz, err := m.MarshalJSON(obj)
if err != nil {
return nil, err
}
Expand All @@ -60,8 +60,8 @@ func MarshalJSONIndent(cdc *Codec, obj interface{}) ([]byte, error) {
}

// MustMarshalJSONIndent executes MarshalJSONIndent except it panics upon failure.
func MustMarshalJSONIndent(cdc *Codec, obj interface{}) []byte {
bz, err := MarshalJSONIndent(cdc, obj)
func MustMarshalJSONIndent(m JSONMarshaler, obj interface{}) []byte {
bz, err := MarshalJSONIndent(m, obj)
if err != nil {
panic(fmt.Sprintf("failed to marshal JSON: %s", err))
}
Expand Down
4 changes: 4 additions & 0 deletions codec/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ type (
UnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler) error
MustUnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler)

JSONMarshaler
}

JSONMarshaler interface {
MarshalJSON(o interface{}) ([]byte, error) // nolint: stdmethods
MustMarshalJSON(o interface{}) []byte

Expand Down
13 changes: 3 additions & 10 deletions contrib/devtools/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all tools tools-clean statik runsim golangci-lint \
.PHONY: all tools tools-clean statik runsim \
protoc buf protoc-gen-buf-check-breaking protoc-gen-buf-check-lint protoc-gen-gocosmos

###
Expand Down Expand Up @@ -47,21 +47,14 @@ UNAME_M ?= $(shell uname -m)

GOPATH ?= $(shell $(GO) env GOPATH)
GITHUBDIR := $(GOPATH)$(FS)src$(FS)github.com
GOLANGCI_LINT_HASHSUM := f11179f445385a4a6d5079d67de63fe48a9113cee8e9ee0ced19327a83a4394b

BUF_VERSION ?= 0.4.0
BUF_VERSION ?= 0.7.0

TOOLS_DESTDIR ?= $(GOPATH)/bin
GOLANGCI_LINT = $(TOOLS_DESTDIR)/golangci-lint
STATIK = $(TOOLS_DESTDIR)/statik
RUNSIM = $(TOOLS_DESTDIR)/runsim

tools: protoc buf statik runsim golangci-lint

golangci-lint: $(GOLANGCI_LINT)
$(GOLANGCI_LINT): $(mkfile_dir)/install-golangci-lint.sh
@echo "Installing golangci-lint..."
@bash $(mkfile_dir)/install-golangci-lint.sh $(TOOLS_DESTDIR) $(GOLANGCI_LINT_HASHSUM)
tools: protoc buf statik runsim

# Install the runsim binary with a temporary workaround of entering an outside
# directory as the "go get" command ignores the -mod option and will polute the
Expand Down
Loading

0 comments on commit d8a693d

Please sign in to comment.