Skip to content

Commit

Permalink
[capricorn] cosmos-sdk v0.42.9 to v0.42.10 (#117)
Browse files Browse the repository at this point in the history
* fix: file keyring fails to add/import/export keys when input is not stdin (fix #9566) (backport #9821) (#9880)

* fix: file keyring fails to add/import/export keys when input is not stdin (fix #9566) (#9821)

## Description

Add a test case to reproduce the issue described in #9566. The test currently fails, and I've pointed some possible solutions over cosmos/cosmos-sdk#9566 (comment). But I feel this needs more works in order to provide a more robust solution. I'll keep poking at better options, but taking any pointers if anyone has ideas.

(cherry picked from commit f479b51)

# Conflicts:
#	client/keys/add.go
#	client/keys/add_test.go
#	client/keys/export_test.go

* fix: merge conflict backporting pr-9821 (#9888)

Co-authored-by: daeMOn <flavien.binet@gmail.com>

* fix: Fix CLI query tx docs for acc/seq (#9942) (#9951)

<!--
The default pull request template is for types feat, fix, or refactor.
For other templates, add one of the following parameters to the url:
- template=docs.md
- template=other.md
-->

## Description

ref: user from #validators-verfied channel on Cosmos Discord

<!-- Add a description of the changes that this PR introduces and the files that
are the most critical to review. -->

* build(deps): bump TM to v0.34.12 (backport #9956) (#9961)

* perf: Remove telemetry from wrappings of store (backport #10077) (#10084)

* docs: update to v0.44 version tag (#10069) (#10097)

(cherry picked from commit d6c3017)

# Conflicts:
#	docs/.vuepress/enhanceApp.js

Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com>

* fix!: update ABCI query to use request height (backport #9879) (#10144)

* fix: use keyring in config for add-genesis-account cmd (backport #9969) (#10065)

* fix: use keyring in config for add-genesis-account cmd (#9969)

<!--
The default pull request template is for types feat, fix, or refactor.
For other templates, add one of the following parameters to the url:
- template=docs.md
- template=other.md
-->

## Description

ref: #9644

+use the keyring backend (if specified) in the binary config for the add-genesis-account command
+update existing test to check for the case of keyring in config

* build(deps): bump github.com/tendermint/tendermint from 0.34.12 to 0.34.13 (backport #10106) (#10107)

* build(deps): bump github.com/tendermint/tendermint (#10106)

(cherry picked from commit 8ee5e50)

* fix go.sum

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* perf: Make CacheKV store interleaved iterator and insertion not O(n^2) (backport #10026) (#10114)

* perf: Make CacheKV store interleaved iterator and insertion not O(n^2) (#10026)

(cherry picked from commit 28bf2c1)

# Conflicts:
#	CHANGELOG.md
#	store/cachekv/store.go

* Fix merge conflict

* fix changelog

Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com>
Co-authored-by: ValarDragon <dojha12@gmail.com>
Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* chore: bump IAVL version (backport #10040) (#10186)

* chore: bump IAVL version (#10040)

* chore: bump IAVL version

* test master

* update IAVL version

* adding missing go.sum entry

* adding missing entries

* fix go.sum

* clear go.sum

* fixing go.sum

Co-authored-by: marbar3778 <marbar3778@yahoo.com>
(cherry picked from commit 693ffb1)

* add changelog update

* tidy go.mod

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* feat: backport reject redundant transactions from ibc-go (#10211)

* backport refund of redundant packets from ibc-go

* update changelog

* address review comments and lint errors

* added nolint

Co-authored-by: Carlos Rodriguez <crodveg@gmail.com>

* chore: Changelog and Release Notes for 0.42.10 (#10242)

* chores: bump tendermint version

* fix: add required helper for group module

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Robert Zaremba <robert@zaremba.ch>
Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com>
Co-authored-by: ValarDragon <dojha12@gmail.com>
Co-authored-by: Carlos Rodriguez <crodveg@yahoo.es>
Co-authored-by: Carlos Rodriguez <crodveg@gmail.com>
Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
  • Loading branch information
10 people authored Nov 24, 2021
1 parent 3e017e7 commit ea940e2
Show file tree
Hide file tree
Showing 24 changed files with 658 additions and 267 deletions.
22 changes: 21 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,33 @@ Ref: https://keepachangelog.com/en/1.0.0/

## Unreleased

## [v0.42.10](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.42.10) - 2021-09-28

### Improvements

* (store) [\#10026](https://github.com/cosmos/cosmos-sdk/pull/10026) Improve CacheKVStore datastructures / algorithms, to no longer take O(N^2) time when interleaving iterators and insertions.
* (store) [\#10040](https://github.com/cosmos/cosmos-sdk/pull/10040) Bump IAVL to v0.17.1 which includes performance improvements on a batch load.
* [\#10211](https://github.com/cosmos/cosmos-sdk/pull/10211) Backport of the mechanism to reject redundant IBC transactions from [ibc-go \#235](https://github.com/cosmos/ibc-go/pull/235).

### Bug Fixes

* [\#9969](https://github.com/cosmos/cosmos-sdk/pull/9969) fix: use keyring in config for add-genesis-account cmd.

### Client Breaking Changes

* [\#9879](https://github.com/cosmos/cosmos-sdk/pull/9879) Modify ABCI Queries to use `abci.QueryRequest` Height field if it is non-zero, otherwise continue using context height.

### API Breaking Changes

* [\#10077](https://github.com/cosmos/cosmos-sdk/pull/10077) Remove telemetry on `GasKV` and `CacheKV` store Get/Set operations, significantly improving their performance.

## [v0.42.9](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.42.9) - 2021-08-04

### Bug Fixes

* [\#9835](https://github.com/cosmos/cosmos-sdk/pull/9835) Moved capability initialization logic to BeginBlocker to fix nondeterminsim issue mentioned in [\#9800](https://github.com/cosmos/cosmos-sdk/issues/9800). Applications must now include the capability module in their BeginBlocker order before any module that uses capabilities gets run.
* [\#9201](https://github.com/cosmos/cosmos-sdk/pull/9201) Fixed `<app> init --recover` flag.


### API Breaking Changes

* [\#9835](https://github.com/cosmos/cosmos-sdk/pull/9835) The `InitializeAndSeal` API has not changed, however it no longer initializes the in-memory state. `InitMemStore` has been introduced to serve this function, which will be called either in `InitChain` or `BeginBlock` (whichever is first after app start). Nodes may run this version on a network running 0.42.x, however, they must update their app.go files to include the capability module in their begin blockers.
Expand All @@ -60,6 +79,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

* (deps) [\#9956](https://github.com/cosmos/cosmos-sdk/pull/9956) Bump Tendermint to [v0.34.12](https://github.com/tendermint/tendermint/releases/tag/v0.34.12).
* (cli) [\#9717](https://github.com/cosmos/cosmos-sdk/pull/9717) Added CLI flag `--output json/text` to `tx` cli commands.

### Bug Fixes
Expand Down
17 changes: 11 additions & 6 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# Cosmos SDK v0.42.9 "Stargate" Release Notes
# Cosmos SDK v0.42.10 "Stargate" Release Notes

This release includes an important `x/capabiliy` module bug fix for 0.42.7 and 0.42.8 which prohibits IBC to create new channels (issuse [\#9800](https://github.com/cosmos/cosmos-sdk/issues/9800)).
The fix changes the `x/capability/keeper/Keeper.InitializeAndSeal` method behavior and requires to update an app module manager by adding x/capability module to Begin Blockers.
This release includes a new `AnteHandler` that rejects redundant IBC transactions to save relayers fees. This is a backport of [ibc-go \#235](https://github.com/cosmos/ibc-go/pull/235).

We also fixed `<app> init --recovery` mode where the mnemonic was not handled correctly.
v0.42.10 also includes multiple performance improvements, such as:

We also changed `<app> tx distribution withdraw-all-rewards` CLI by forcing the broadcast mode if a chunk size is greater than 0. This will ensure that the transactions do not fail even if the user uses invalid broadcast modes for this command (sync and async). This was requested by the community and we consider it as fixing the `withdraw-all-rewards` behavior.
- improve ABCI performance under concurrent load via [Tendermint v0.34.13](https://github.com/tendermint/tendermint/blob/master/CHANGELOG.md#v03413),
- improve CacheKVStore datastructures / algorithms, to no longer take O(N^2) time when interleaving iterators and insertions.
- bump IAVL to v0.17.1 which includes performance improvements on a batch load.

See the [Cosmos SDK v0.42.9 milestone](https://github.com/cosmos/cosmos-sdk/milestone/53?closed=1) on our issue tracker for the exhaustive list of all changes.
We fixed the keyring to use pre-configured data for `add-genesis-account` command.

Finally, when using the `client.Context`, we modified ABCI queries to use `abci.QueryRequest`'s `Height` field if it is non-zero, otherwise continue using `client.Context`'s height. This is a minor client-breaking change for users of the `client.Context`.

See the [Cosmos SDK v0.42.10 milestone](https://github.com/cosmos/cosmos-sdk/milestone/55?closed=1) on our issue tracker for the exhaustive list of all changes.
6 changes: 5 additions & 1 deletion client/context.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package client

import (
"bufio"
"encoding/json"
"io"
"os"
Expand Down Expand Up @@ -60,7 +61,10 @@ func (ctx Context) WithKeyring(k keyring.Keyring) Context {

// WithInput returns a copy of the context with an updated input.
func (ctx Context) WithInput(r io.Reader) Context {
ctx.Input = r
// convert to a bufio.Reader to have a shared buffer between the keyring and the
// the Commands, ensuring a read from one advance the read pointer for the other.
// see https://github.com/cosmos/cosmos-sdk/issues/9566.
ctx.Input = bufio.NewReader(r)
return ctx
}

Expand Down
5 changes: 3 additions & 2 deletions client/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ func RunGRPCQuery(ctx Context, grpcCtx gocontext.Context, method string, req int
}

abciReq := abci.RequestQuery{
Path: method,
Data: reqBz,
Path: method,
Data: reqBz,
Height: ctx.Height,
}

abciRes, err := ctx.QueryABCI(abciReq)
Expand Down
3 changes: 1 addition & 2 deletions client/keys/add_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package keys

import (
"bufio"
"context"
"fmt"
"testing"
Expand Down Expand Up @@ -124,7 +123,7 @@ func TestAddRecoverFileBackend(t *testing.T) {
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)
kbHome := t.TempDir()

clientCtx := client.Context{}.WithKeyringDir(kbHome).WithInput(bufio.NewReader(mockIn))
clientCtx := client.Context{}.WithKeyringDir(kbHome).WithInput(mockIn)
ctx := context.WithValue(context.Background(), client.ClientContextKey, &clientCtx)

cmd.SetArgs([]string{
Expand Down
143 changes: 90 additions & 53 deletions client/keys/export_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package keys

import (
"bytes"
"bufio"
"context"
"fmt"
"testing"
Expand All @@ -18,58 +18,95 @@ import (
)

func Test_runExportCmd(t *testing.T) {
cmd := ExportKeyCommand()
cmd.Flags().AddFlagSet(Commands("home").PersistentFlags())
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)

// Now add a temporary keybase
kbHome := t.TempDir()

// create a key
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, nil)
require.NoError(t, err)
t.Cleanup(func() {
kb.Delete("keyname1") // nolint:errcheck
})

path := sdk.GetConfig().GetFullFundraiserPath()
_, err = kb.NewAccount("keyname1", testutil.TestMnemonic, "", path, hd.Secp256k1)
require.NoError(t, err)

// Now enter password
args := []string{
"keyname1",
fmt.Sprintf("--%s=%s", flags.FlagHome, kbHome),
fmt.Sprintf("--%s=%s", flags.FlagKeyringBackend, keyring.BackendTest),
testCases := []struct {
name string
keyringBackend string
extraArgs []string
userInput string
mustFail bool
expectedOutput string
}{
{
name: "--unsafe only must fail",
keyringBackend: keyring.BackendTest,
extraArgs: []string{"--unsafe"},
mustFail: true,
},
{
name: "--unarmored-hex must fail",
keyringBackend: keyring.BackendTest,
extraArgs: []string{"--unarmored-hex"},
mustFail: true,
},
{
name: "--unsafe --unarmored-hex fail with no user confirmation",
keyringBackend: keyring.BackendTest,
extraArgs: []string{"--unsafe", "--unarmored-hex"},
userInput: "",
mustFail: true,
expectedOutput: "",
},
{
name: "--unsafe --unarmored-hex succeed",
keyringBackend: keyring.BackendTest,
extraArgs: []string{"--unsafe", "--unarmored-hex"},
userInput: "y\n",
mustFail: false,
expectedOutput: "2485e33678db4175dc0ecef2d6e1fc493d4a0d7f7ce83324b6ed70afe77f3485\n",
},
{
name: "file keyring backend properly read password and user confirmation",
keyringBackend: keyring.BackendFile,
extraArgs: []string{"--unsafe", "--unarmored-hex"},
// first 2 pass for creating the key, then unsafe export confirmation, then unlock keyring pass
userInput: "12345678\n12345678\ny\n12345678\n",
mustFail: false,
expectedOutput: "2485e33678db4175dc0ecef2d6e1fc493d4a0d7f7ce83324b6ed70afe77f3485\n",
},
}

mockIn.Reset("123456789\n123456789\n")
cmd.SetArgs(args)

clientCtx := client.Context{}.
WithKeyringDir(kbHome).
WithKeyring(kb).
WithInput(mockIn)
ctx := context.WithValue(context.Background(), client.ClientContextKey, &clientCtx)

require.NoError(t, cmd.ExecuteContext(ctx))

argsUnsafeOnly := append(args, "--unsafe")
cmd.SetArgs(argsUnsafeOnly)
require.Error(t, cmd.ExecuteContext(ctx))

argsUnarmoredHexOnly := append(args, "--unarmored-hex")
cmd.SetArgs(argsUnarmoredHexOnly)
require.Error(t, cmd.ExecuteContext(ctx))

argsUnsafeUnarmoredHex := append(args, "--unsafe", "--unarmored-hex")
cmd.SetArgs(argsUnsafeUnarmoredHex)
require.Error(t, cmd.ExecuteContext(ctx))

mockOut := bytes.NewBufferString("")
cmd.SetOut(mockOut)
cmd.SetErr(mockOut)
mockIn.Reset("y\n")
require.NoError(t, cmd.ExecuteContext(ctx))
require.Equal(t, "2485e33678db4175dc0ecef2d6e1fc493d4a0d7f7ce83324b6ed70afe77f3485\n", mockOut.String())
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
kbHome := t.TempDir()
defaultArgs := []string{
"keyname1",
fmt.Sprintf("--%s=%s", flags.FlagHome, kbHome),
fmt.Sprintf("--%s=%s", flags.FlagKeyringBackend, tc.keyringBackend),
}

cmd := ExportKeyCommand()
cmd.Flags().AddFlagSet(Commands("home").PersistentFlags())

cmd.SetArgs(append(defaultArgs, tc.extraArgs...))
mockIn, mockOut := testutil.ApplyMockIO(cmd)

mockIn.Reset(tc.userInput)
mockInBuf := bufio.NewReader(mockIn)

// create a key
kb, err := keyring.New(sdk.KeyringServiceName(), tc.keyringBackend, kbHome, bufio.NewReader(mockInBuf))
require.NoError(t, err)
t.Cleanup(func() {
kb.Delete("keyname1") // nolint:errcheck
})

path := sdk.GetConfig().GetFullFundraiserPath()
_, err = kb.NewAccount("keyname1", testutil.TestMnemonic, "", path, hd.Secp256k1)
require.NoError(t, err)

clientCtx := client.Context{}.
WithKeyringDir(kbHome).
WithKeyring(kb).
WithInput(mockInBuf)
ctx := context.WithValue(context.Background(), client.ClientContextKey, &clientCtx)

err = cmd.ExecuteContext(ctx)
if tc.mustFail {
require.Error(t, err)
} else {
require.NoError(t, err)
require.Equal(t, tc.expectedOutput, mockOut.String())
}
})
}
}
Loading

0 comments on commit ea940e2

Please sign in to comment.