Skip to content

Commit

Permalink
Merge pull request #23 from vulcanize/sai/cherry_picks_for_fix_upgrade
Browse files Browse the repository at this point in the history
fix: fix the json state migrations of v0.46
  • Loading branch information
i-norden authored Jun 22, 2022
2 parents 1a6a5a0 + b6f92db commit ce584a4
Show file tree
Hide file tree
Showing 18 changed files with 354 additions and 130 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,20 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

* (cli) [#12028](https://github.com/cosmos/cosmos-sdk/pull/12028) Add the `tendermint key-migrate` to perform Tendermint v0.35 DB key migration.

### Bug Fixes

* (migrations) [#12028](https://github.com/cosmos/cosmos-sdk/pull/12028) Fix v0.45->v0.46 in-place store migrations.
* (baseapp) [#12089](https://github.com/cosmos/cosmos-sdk/pull/12089) Include antehandler and runMsgs events in SimulateTx.
* (cli) [#12095](https://github.com/cosmos/cosmos-sdk/pull/12095) Fix running a tx with --dry-run returns an error
* (x/auth) [#12108](https://github.com/cosmos/cosmos-sdk/pull/12108) Fix GetBlockWithTxs error when querying block with 0 tx
* (genutil) [#12140](https://github.com/cosmos/cosmos-sdk/pull/12140) Fix staking's genesis JSON migrate in the `simd migrate v0.46` CLI command.

## [v0.46.0-rc1](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.0-rc1) - 2022-05-23

### Features

* (types) [#11985](https://github.com/cosmos/cosmos-sdk/pull/11985) Add a `Priority` field on `sdk.Context`, which represents the CheckTx priority field. It is only used during CheckTx.
* (gRPC) [#11889](https://github.com/cosmos/cosmos-sdk/pull/11889) Support custom read and write gRPC options in `app.toml`. See `max-recv-msg-size` and `max-send-msg-size` respectively.
* (cli) [\#11738](https://github.com/cosmos/cosmos-sdk/pull/11738) Add `tx auth multi-sign` as alias of `tx auth multisign` for consistency with `multi-send`.
* (cli) [\#11738](https://github.com/cosmos/cosmos-sdk/pull/11738) Add `tx bank multi-send` command for bulk send of coins to multiple accounts.
Expand Down Expand Up @@ -343,6 +354,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (store) [\#11117](https://github.com/cosmos/cosmos-sdk/pull/11117) Fix data race in store trace component
* (x/authz) [\#11252](https://github.com/cosmos/cosmos-sdk/pull/11252) Allow insufficient funds error for authz simulation
* (crypto) [\#11298](https://github.com/cosmos/cosmos-sdk/pull/11298) Fix cgo secp signature verification and update libscep256k1 library.
* (crypto) [\#12122](https://github.com/cosmos/cosmos-sdk/pull/12122) Fix keyring migration issue.

### Improvements

Expand Down
2 changes: 2 additions & 0 deletions baseapp/abci_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !race

package baseapp

import (
Expand Down
3 changes: 3 additions & 0 deletions baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !race
// +build !race

package baseapp

import (
Expand Down
10 changes: 6 additions & 4 deletions crypto/keyring/keyring.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,10 @@ func (ks keystore) List() ([]*Record, error) {
var res []*Record //nolint:prealloc
sort.Strings(keys)
for _, key := range keys {
if strings.HasSuffix(key, addressSuffix) {
// Recall that each key is twice in the keyring:
// - once with the `.info` suffix, which holds the key info
// - another time with the `.address` suffix, which only holds a reference to its associated `.info` key
if !strings.HasSuffix(key, infoSuffix) {
continue
}

Expand Down Expand Up @@ -872,9 +875,8 @@ func (ks keystore) MigrateAll() error {
}

for _, key := range keys {
// The keyring items with `.address` suffix only holds as Data the
// key name uid, so there's nothing to migrate.
if strings.HasSuffix(key, addressSuffix) {
// The keyring items only with `.info` consists the key info.
if !strings.HasSuffix(key, infoSuffix) {
continue
}

Expand Down
14 changes: 13 additions & 1 deletion crypto/keyring/keyring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package keyring
import (
"encoding/hex"
"fmt"
"os"
"path/filepath"
"strings"
"testing"

Expand Down Expand Up @@ -59,7 +61,8 @@ func TestNewKeyring(t *testing.T) {

func TestKeyManagementKeyRing(t *testing.T) {
cdc := getCodec()
kb, err := New("keybasename", "test", t.TempDir(), nil, cdc)
tempDir := t.TempDir()
kb, err := New("keybasename", "test", tempDir, nil, cdc)
require.NoError(t, err)
require.NotNil(t, cdc)

Expand Down Expand Up @@ -151,6 +154,15 @@ func TestKeyManagementKeyRing(t *testing.T) {
require.NoError(t, err)
require.Equal(t, 1, len(keyS))

// create some random directory inside the keyring directory to check migrate ignores
// all files other than *.info
newPath := filepath.Join(tempDir, "random")
require.NoError(t, os.Mkdir(newPath, 0755))
items, err := os.ReadDir(tempDir)
require.GreaterOrEqual(t, len(items), 2)
keyS, err = kb.List()
require.NoError(t, err)

// addr cache gets nuked - and test skip flag
require.NoError(t, kb.Delete(n2))
}
Expand Down
36 changes: 18 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,24 @@ require (
github.com/spf13/cast v1.5.0
github.com/spf13/cobra v1.4.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.11.0
github.com/spf13/viper v1.12.0
github.com/stretchr/testify v1.7.1
github.com/tendermint/btcd v0.1.1
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15
github.com/tendermint/go-amino v0.16.0
github.com/tendermint/tendermint v0.35.4
github.com/tendermint/tendermint v0.35.6
github.com/tendermint/tm-db v0.6.6
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4
google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac
google.golang.org/grpc v1.46.2
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd
google.golang.org/grpc v1.47.0
google.golang.org/protobuf v1.28.0
pgregory.net/rapid v0.4.7
sigs.k8s.io/yaml v1.3.0
)

require (
cloud.google.com/go v0.100.2 // indirect
cloud.google.com/go/compute v1.5.0 // indirect
cloud.google.com/go/compute v1.6.1 // indirect
cloud.google.com/go/iam v0.3.0 // indirect
cloud.google.com/go/storage v1.14.0 // indirect
filippo.io/edwards25519 v1.0.0-rc.1 // indirect
Expand All @@ -87,7 +87,7 @@ require (
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c // indirect
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 // indirect
github.com/felixge/httpsnoop v1.0.1 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/golang/glog v1.0.0 // indirect
Expand All @@ -96,7 +96,7 @@ require (
github.com/google/btree v1.0.1 // indirect
github.com/google/flatbuffers v2.0.0+incompatible // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/googleapis/gax-go/v2 v2.3.0 // indirect
github.com/googleapis/gax-go/v2 v2.4.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
Expand All @@ -110,17 +110,17 @@ require (
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/lib/pq v1.10.5 // indirect
github.com/lib/pq v1.10.6 // indirect
github.com/libp2p/go-buffer-pool v0.0.2 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/minio/highwayhash v1.0.2 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/oasisprotocol/curve25519-voi v0.0.0-20210609091139-0a56a4bca00b // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/pelletier/go-toml/v2 v2.0.0-beta.8 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
Expand All @@ -130,25 +130,25 @@ require (
github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/subosito/gotenv v1.3.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect
github.com/ulikunitz/xz v0.5.8 // indirect
github.com/zondax/hid v0.9.1-0.20220302062450-5552068d2266 // indirect
go.etcd.io/bbolt v1.3.6 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/net v0.0.0-20220412020605-290c469a71a5 // indirect
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 // indirect
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e // indirect
golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
google.golang.org/api v0.74.0 // indirect
golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect
google.golang.org/api v0.81.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
gopkg.in/yaml.v3 v3.0.0 // indirect
nhooyr.io/websocket v1.8.6 // indirect
)

Expand Down
Loading

0 comments on commit ce584a4

Please sign in to comment.