Skip to content

Commit af5edde

Browse files
committed
Merge remote-tracking branch 'upstream/launchpad/backports' into release/v0.39.2-celer.1
2 parents 0152b34 + 6a624c3 commit af5edde

File tree

21 files changed

+1087
-288
lines changed

21 files changed

+1087
-288
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ Ref: https://keepachangelog.com/en/1.0.0/
3535

3636
# Changelog
3737

38+
## [v0.39.1]
39+
40+
* (x/auth) [\#6861](https://github.com/cosmos/cosmos-sdk/pull/6861) Remove public key Bech32 encoding for all account types for JSON serialization, instead relying on direct Amino encoding. In addition, JSON serialization utilizes Amino instead of the Go stdlib, so integers are treated as strings.
41+
* (client) [\#6853](https://github.com/cosmos/cosmos-sdk/pull/6853) Add --unsafe-cors flag.
42+
3843
## [v0.39.0]
3944

4045
### Improvements
@@ -2949,7 +2954,9 @@ BUG FIXES:
29492954

29502955
<!-- Release links -->
29512956

2952-
[Unreleased]: https://github.com/cosmos/cosmos-sdk/compare/v0.38.2...HEAD
2957+
[Unreleased]: https://github.com/cosmos/cosmos-sdk/compare/v0.39.1...HEAD
2958+
[v0.39.1]: https://github.com/cosmos/cosmos-sdk/releases/tag/v0.39.1
2959+
[v0.39.0]: https://github.com/cosmos/cosmos-sdk/releases/tag/v0.39.0
29532960
[v0.38.2]: https://github.com/cosmos/cosmos-sdk/releases/tag/v0.38.2
29542961
[v0.38.1]: https://github.com/cosmos/cosmos-sdk/releases/tag/v0.38.1
29552962
[v0.38.0]: https://github.com/cosmos/cosmos-sdk/releases/tag/v0.38.0

RELEASE_NOTES.md

Lines changed: 12 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,20 @@
1-
# Cosmos SDK v0.39.0 Release Notes
1+
# Cosmos SDK v0.39.1 Release Notes
22

3-
This is the inaugural release of the **Cosmos SDK 0.39 «Launchpad»** release series.
3+
This release fixes the [issue affecting the accounts migration](https://github.com/cosmos/cosmos-sdk/issues/6828) from v0.38 to v0.39.
44

5-
See the [Cosmos SDK 0.39.0 milestone](https://github.com/cosmos/cosmos-sdk/milestone/27?closed=1) on our issue tracker for details.
5+
See the [Cosmos SDK 0.39.1 milestone](https://github.com/cosmos/cosmos-sdk/milestone/29?closed=1) on our issue tracker for details.
66

7-
## Changes to IAVL and store pruning
7+
## Remove custom JSON serialization for account types
88

9-
The pruning features introduced in the `0.38` release series are buggy and might lead to data loss,
10-
even after upgrading to `v0.39.0`. When upgrading from `0.38` it is important to follow the instructions
11-
below, to prevent data loss and database corruption.
9+
Account types JSON serialization has now changed to Amino. Changes are significant (e.g. integers are treated
10+
as strings) thus it is required to migrate the exported state of an application before restarting the node
11+
with a more recent version of the Cosmos SDK.
1212

13-
**Note: there are are several breaking changes with regard to IAVL, stores, and pruning settings that affect command line clients, server configuration, and Golang API.**
13+
## REST server's --unsafe-cors mode
1414

15-
### Migrate an application from 0.38.5 to 0.39.0
15+
This a UX improvement [back ported from master](https://github.com/cosmos/cosmos-sdk/pull/6853) that allows developers to disable CORS
16+
restrictions during app development and testing by passing the `--unsafe-cors` option to the client's `rest-server` command.
1617

17-
The IAVL's `v0.13.0` release introduced a pruning functionality that turned out to be buggy and flawed.
18-
IAVL's new `v0.14.0` release now commits and flushes every state to disk as it did in pre-`v0.13.0` release.
19-
The SDK's multi-store will track and ensure the proper heights are pruned. The operator can now set the pruning
20-
options by passing a `pruning` configuration via command line option or `app.toml`. The `pruning` flag supports the following
21-
options: `default`, `everything`, `nothing`, `custom` - see docs for further details. If the operator chooses `custom`, they
22-
may want to provide either of the granular pruning values:
23-
- `pruning-keep-recent`
24-
- `pruning-keep-every`
25-
- `pruning-interval`
18+
## Tendermint 0.33.7
2619

27-
The former two options dictate how many recent versions are kept on disk and the offset of what versions are kept after that
28-
respectively, and the latter defines the height interval in which versions are deleted in a batch. **Note: there are are some
29-
client application breaking changes with regard to IAVL, stores, and pruning settings.** An example patch follows:
30-
31-
```patch
32-
From 5884171ba73c3054e98564c39adc9cbbab8d4646 Mon Sep 17 00:00:00 2001
33-
From: Alessio Treglia <alessio@tendermint.com>
34-
Date: Tue, 14 Jul 2020 14:54:19 +0100
35-
Subject: [PATCH 2/4] use new pruning options
36-
37-
---
38-
cmd/cnd/main.go | 8 ++++++--
39-
1 file changed, 6 insertions(+), 2 deletions(-)
40-
41-
diff --git a/cmd/cnd/main.go b/cmd/cnd/main.go
42-
index b0c86f4a..4a3a8518 100644
43-
--- a/cmd/cnd/main.go
44-
+++ b/cmd/cnd/main.go
45-
@@ -23,7 +23,6 @@ import (
46-
comgenutilcli "github.com/commercionetwork/commercionetwork/x/genutil/client/cli"
47-
"github.com/cosmos/cosmos-sdk/baseapp"
48-
"github.com/cosmos/cosmos-sdk/server"
49-
- "github.com/cosmos/cosmos-sdk/store"
50-
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
51-
"github.com/cosmos/cosmos-sdk/x/staking"
52-
)
53-
@@ -87,9 +86,14 @@ func main() {
54-
}
55-
56-
func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer) abci.Application {
57-
+ pruningOpts, err := server.GetPruningOptionsFromFlags()
58-
+ if err != nil {
59-
+ panic(err)
60-
+ }
61-
+
62-
return app.NewCommercioNetworkApp(
63-
logger, db, traceStore, true, invCheckPeriod,
64-
- baseapp.SetPruning(store.NewPruningOptionsFromString(viper.GetString("pruning"))),
65-
+ baseapp.SetPruning(pruningOpts),
66-
baseapp.SetMinGasPrices(viper.GetString(server.FlagMinGasPrices)),
67-
baseapp.SetHaltHeight(uint64(viper.GetInt(server.FlagHaltHeight))),
68-
)
69-
```
70-
71-
### Migrate a node from 0.38.5 to 0.39.0
72-
73-
Note: **do not modify pruning settings with any release prior to `v0.39.0` as that may cause data corruption**.
74-
75-
The following instructions assume that **pruning settings have not been modified since the node started using 0.38.x. Note: the default pruning setting `syncable` used `KeepEvery:100`.
76-
77-
#### Chain Hard Fork (also know as The Tested Upgrade Path)
78-
79-
This strategy entails performing a hard fork of your chain.
80-
It takes time, coordination and a few technical steps that the validators of the network must follow. Note: a software upgrade guide for `gaia`, the application that powers the Cosmos Hub, is [available too](https://hub.cosmos.network/master/gaia-tutorials/upgrade-node.html). It contains detailed instructions on how to upgrade network nodes that apply to the vast majority of Cosmos SDK applications.
81-
82-
In preparation of the upgrade, you need to export the current state. This operation should be be performed on one node:
83-
84-
* Stop the node and export the current state, e.g.: `appd export --for-zero-height > export_genesis.json`.
85-
* Manually replace the chain id and genesis time fields in `export_genesis.json` with the values that the network had agreed upon.
86-
87-
Follow these steps to perform the upgrade:
88-
89-
* Make a backup copy of the old `genesis.json` file in your server application's config directory (e.g. `$HOME/.appd/config/genesis.json`) and replace it with `export_genesis.json`. Note: do rename `export_genesis.json` to `genesis.json`.
90-
* Replace the old binary with the new one and restart the service using the new binary.
91-
92-
#### Alternative strategies
93-
94-
Alternatively, you can follow *one of* the following strategies:
95-
96-
* Replace the application server's binary and perform a full sync of the node from scratch.
97-
98-
* If your node had started with using `KeepEvery:1` (e.g. pruning settings `nothing` or `everything`), upgrading to `v0.39.0` should be simple and safe.
99-
100-
* Do halt block processing with `--halt-height` after committing a height divisible by `KeepEvery` - e.g. at block 147600 with `KeepEvery:100`. The **node must never have processed a height beyond that at any time in its past**. Upgrading to `v0.39.0` is then safe.
101-
102-
* Set the `KeepEvery` setting to the same as the previous `KeepEvery` setting (both `<=v0.38.5` and `v0.39.0` default to `KeepEvery:100`). Upgrade to `v0.39.0` is then safe as long as you wait one `KeepEvery` interval plus one `KeepRecent` interval **plus** one pruning `Interval` before changing pruning settings or deleting the last `<=v0.38.5` height (so wait *210* heights with the default configuration).
103-
104-
* Otherwise, make sure the last version persisted with `<=v0.38.5` is never deleted after upgrading to `v0.39.0`, as doing so may cause data loss and data corruption.
105-
106-
## Regression in the signature verification when multiple transactions in the same block are sent from the same account
107-
108-
When multiple transactions in the same block are sent (and correctly signed) by the same account, chances are that some of them could be rejected and the error `unauthorized: signature verification failed` would be returned due to the account's sequence (*nonce*) getting stuck and not being incremented by the ante handler. This behaviour was [a regression](https://github.com/cosmos/cosmos-sdk/issues/6287) introduced in the `v0.38` release series, it did not occur in the `v0.37` release series and is now fixed in this release.
109-
110-
## Changes to ABCI Query's "app/simulate" path
111-
112-
The `app/simulate` query path is used to simulate the execution transactions in order to obtain an estimate
113-
of the gas consumption that would be required to actually execute them. The response used to return only
114-
the amount of gas, it now returns the result of the transaction as well.
115-
116-
## bank.send event comes with sender information
117-
118-
The `bank.send` event used to carry only the recipient and amount. It was assumed that the sender of the funds was `message.sender`.
119-
This is often not true when a module call the bank keeper directly. This may be due to staking distribution, or via a cosmwasm contract that released funds (where I discovered the issue).
120-
121-
`bank.send` now contains the entire triple `(sender, recipient, amount)`.
122-
123-
## trace option is no longer ignored
124-
125-
The `--trace` option is reintroduced. It comes in very handy for debugging as it causes the full stack trace to be included in the ABCI error logs.
126-
127-
## appcli keys parse command didn't honor client application's bech32 prefixes
128-
129-
The `key parse` command ignored the application-specific address bech32
130-
prefixes and used to return `cosmos*1`-prefixed addresses regardless
131-
of the client application's configuration.
20+
Tendermint 0.33.7 brings an important regression fix. Please refer to [this bug report](https://github.com/tendermint/tendermint/issues/5112) for more information.

client/flags/flags.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ const (
6868
FlagKeyringBackend = "keyring-backend"
6969
FlagPage = "page"
7070
FlagLimit = "limit"
71+
FlagUnsafeCORS = "unsafe-cors"
7172
)
7273

7374
// LineBreak can be included in a command list to provide a blank line
@@ -141,6 +142,7 @@ func RegisterRestServerFlags(cmd *cobra.Command) *cobra.Command {
141142
cmd.Flags().Uint(FlagMaxOpenConnections, 1000, "The number of maximum open connections")
142143
cmd.Flags().Uint(FlagRPCReadTimeout, 10, "The RPC read timeout (in seconds)")
143144
cmd.Flags().Uint(FlagRPCWriteTimeout, 10, "The RPC write timeout (in seconds)")
145+
cmd.Flags().Bool(FlagUnsafeCORS, false, "Allows CORS requests from all domains. For development purposes only, use it at your own risk.")
144146

145147
return cmd
146148
}

client/lcd/root.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"os"
88
"time"
99

10+
"github.com/gorilla/handlers"
1011
"github.com/gorilla/mux"
1112
"github.com/rakyll/statik/fs"
1213
"github.com/spf13/cobra"
@@ -46,7 +47,7 @@ func NewRestServer(cdc *codec.Codec) *RestServer {
4647
}
4748

4849
// Start starts the rest server
49-
func (rs *RestServer) Start(listenAddr string, maxOpen int, readTimeout, writeTimeout uint) (err error) {
50+
func (rs *RestServer) Start(listenAddr string, maxOpen int, readTimeout, writeTimeout uint, cors bool) (err error) {
5051
server.TrapSignal(func() {
5152
err := rs.listener.Close()
5253
rs.log.Error("error closing listener", "err", err)
@@ -68,7 +69,13 @@ func (rs *RestServer) Start(listenAddr string, maxOpen int, readTimeout, writeTi
6869
),
6970
)
7071

71-
return tmrpcserver.Serve(rs.listener, rs.Mux, rs.log, cfg)
72+
var h http.Handler = rs.Mux
73+
if cors {
74+
allowAllCORS := handlers.CORS(handlers.AllowedHeaders([]string{"Content-Type"}))
75+
h = allowAllCORS(h)
76+
}
77+
78+
return tmrpcserver.Serve(rs.listener, h, rs.log, cfg)
7279
}
7380

7481
// ServeCommand will start the application REST service as a blocking process. It
@@ -90,6 +97,7 @@ func ServeCommand(cdc *codec.Codec, registerRoutesFn func(*RestServer)) *cobra.C
9097
viper.GetInt(flags.FlagMaxOpenConnections),
9198
uint(viper.GetInt(flags.FlagRPCReadTimeout)),
9299
uint(viper.GetInt(flags.FlagRPCWriteTimeout)),
100+
viper.GetBool(flags.FlagUnsafeCORS),
93101
)
94102

95103
return err

docs/interfaces/rest.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ synopsis: "This document describes how to create a REST interface for an SDK **a
77

88
## Prerequisites {hide}
99

10-
* [Query Lifecycle](./query-lifecycle.md) {prereq}
11-
* [Application CLI](./cli.md) {prereq}
10+
- [Query Lifecycle](./query-lifecycle.md) {prereq}
11+
- [Application CLI](./cli.md) {prereq}
1212

13-
## Application REST Interface
13+
## Application REST Interface
1414

1515
Building the REST Interface for an application is done by [aggregating REST Routes](#registering-routes) defined in the application's modules. This interface is served by a REST Server [REST server](#rest-server), which route requests and output responses in the application itself. The SDK comes with its own REST Server by default. To enable it, the `rest.ServeCommand` command needs to be added as a subcommand of the `rootCmd` in the `main()` function of the [CLI interface](./cli.md):
1616

@@ -24,27 +24,27 @@ Users will then be able to use the application CLI to start a new REST server, a
2424
appcli rest-server --chain-id <chainID> --trust-node
2525
```
2626

27-
Note that if `trust-node` is set to `false`, the REST server will verify the query proof against the merkle root (contained in the block header).
27+
Note that if `trust-node` is set to `false`, the REST server will verify the query proof against the merkle root (contained in the block header).
2828

2929
## REST Server
3030

3131
A REST Server is used to receive and route HTTP Requests, obtain the results from the application, and return a response to the user. The REST Server defined by the SDK `rest` package contains the following:
3232

33-
* **Router:** A router for HTTP requests. A new router can be instantiated for an application and used to match routes based on path, request method, headers, etc. The SDK uses the [Gorilla Mux Router](https://github.com/gorilla/mux).
34-
* **CLIContext:** A [`CLIContext`](./query-lifecycle.md#clicontext) created for a user interaction.
35-
* **Keybase:** A [Keybase](../basics/accounts.md#keybase) is a key manager.
36-
* **Logger:** A logger from Tendermint `Log`, a log package structured around key-value pairs that allows logging level to be set differently for different keys. The logger takes `Debug()`, `Info()`, and `Error()`s.
37-
* **Listener:** A [listener](https://golang.org/pkg/net/#Listener) from the net package.
33+
- **Router:** A router for HTTP requests. A new router can be instantiated for an application and used to match routes based on path, request method, headers, etc. The SDK uses the [Gorilla Mux Router](https://github.com/gorilla/mux).
34+
- **CLIContext:** A [`CLIContext`](./query-lifecycle.md#clicontext) created for a user interaction.
35+
- **Keybase:** A [Keybase](../basics/accounts.md#keybase) is a key manager.
36+
- **Logger:** A logger from Tendermint `Log`, a log package structured around key-value pairs that allows logging level to be set differently for different keys. The logger takes `Debug()`, `Info()`, and `Error()`s.
37+
- **Listener:** A [listener](https://golang.org/pkg/net/#Listener) from the net package.
3838

39-
Of the five, the only attribute that application developers need interact with is the `router`: they need to add routes to it so that the REST server can properly handle queries. See the next section for more information on registering routes.
39+
Of the five, the only attribute that application developers need interact with is the `router`: they need to add routes to it so that the REST server can properly handle queries. See the next section for more information on registering routes.
4040

4141
In order to enable the REST Server in an SDK application, the `rest.ServeCommand` needs to be added to the application's command-line interface. See the [above section](#application-rest-interface) for more information.
4242

4343
## Registering Routes
4444

4545
To include routes for each module in an application, the CLI must have some kind of function to register routes in its REST Server. This function is called `RegisterRoutes()`, and is utilized by the `ServeCommand` and must include routes for each of the application's modules. Since each module used by an SDK application implements a [`RegisterRESTRoutes`](../building-modules/module-interfaces.md#rest) function, application developers simply use the [Module Manager](../building-modules/module-manager.md) to call this function for each module (this is done in the [application's constructor](../basics/app-anatomy.md#constructor-function)).
4646

47-
At the bare minimum, a `RegisterRoutes()` function should use the SDK client package `RegisterRoutes()` function to be able to route RPC calls, and instruct the application Module Manager to call `RegisterRESTRoutes()` for all of its modules. This is done in the `main.go` file of the CLI (typically located in `./cmd/appcli/main.go`).
47+
At the bare minimum, a `RegisterRoutes()` function should use the SDK client package `RegisterRoutes()` function to be able to route RPC calls, and instruct the application Module Manager to call `RegisterRESTRoutes()` for all of its modules. This is done in the `main.go` file of the CLI (typically located in `./cmd/appcli/main.go`).
4848

4949
```go
5050
func registerRoutes(rs *rest.RestServer) {
@@ -58,3 +58,14 @@ This function is specific to the application and passed in to the `ServeCommand`
5858
```go
5959
rootCmd.AddCommand(rest.ServeCommand(cdc, registerRoutes))
6060
```
61+
62+
## Cross-Origin Resource Sharing (CORS)
63+
64+
[CORS policies](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) are not enabled by default to help with security. If you would like to use the rest-server in a public environment we recommend you provide a reverse proxy, this can be done with [nginx](https://www.nginx.com/). For testing and development purposes there is an `unsafe_cors` flag that can be passed to the cmd to enable accepting cors from everyone.
65+
66+
```sh
67+
gaiacli rest-server --chain-id=test \
68+
--laddr=tcp://localhost:1317 \
69+
--node tcp://localhost:26657 \
70+
--trust-node=true --unsafe-cors
71+
```

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ require (
1111
github.com/cosmos/ledger-cosmos-go v0.11.1
1212
github.com/gogo/protobuf v1.3.1
1313
github.com/golang/mock v1.3.1-0.20190508161146-9fa652df1129
14+
github.com/gorilla/handlers v1.4.2
1415
github.com/gorilla/mux v1.7.4
1516
github.com/hashicorp/golang-lru v0.5.4
1617
github.com/mattn/go-isatty v0.0.12
@@ -27,7 +28,7 @@ require (
2728
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15
2829
github.com/tendermint/go-amino v0.15.1
2930
github.com/tendermint/iavl v0.14.0
30-
github.com/tendermint/tendermint v0.33.6
31+
github.com/tendermint/tendermint v0.33.7
3132
github.com/tendermint/tm-db v0.5.1
3233
google.golang.org/grpc v1.30.0 // indirect
3334
gopkg.in/yaml.v2 v2.3.0

0 commit comments

Comments
 (0)