Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V0.44.5 patches -> v 0.45.0 patches #168

Closed
Closed
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7ef483e
fix: types/errors Wrap and Wrapf (backport #10674) (#10676)
mergify[bot] Dec 6, 2021
d404619
fix: Charge gas even when there are no entries in gaskv (backport #10…
mergify[bot] Dec 8, 2021
e01217c
feat: add configurable iavl cache size (backport #10561) (#10698)
mergify[bot] Dec 8, 2021
b9250f3
feat: Add `HasSupply` method to bank keeper (backport #10393) (#10699)
mergify[bot] Dec 9, 2021
16da4a4
fix!: Charge gas for key length in gas meter (backport #10247) (#10697)
mergify[bot] Dec 10, 2021
a8a1101
build(deps): upgrade rosetta to 0.7.0 (backport #10432) (#10716)
mergify[bot] Dec 10, 2021
ad443cb
perf: Speedup cachekv iterator on large deletions & IBC v2 upgrade lo…
mergify[bot] Dec 13, 2021
51f7d31
fix: populate ctx.ConsensusParams for begin blockers (backport #10725…
mergify[bot] Dec 16, 2021
f67928a
fix: nil pointer panic on `NewIntFromBigInt` (backport #9627) (#10845)
mergify[bot] Dec 29, 2021
8ad8d5d
perf: Improve the speed of coins.String() (backport #10076) (#10850)
mergify[bot] Dec 30, 2021
1321bc1
perf!: Add HasAccount to the AuthKeeper to save protobuf decoding tim…
mergify[bot] Dec 31, 2021
7115d3b
fix: enable setting sequence (nonce) for module account (backport #10…
mergify[bot] Jan 3, 2022
14cd943
perf: store/cachekv: avoid a map lookup if unnecessary, clear maps fa…
mergify[bot] Jan 3, 2022
19e924d
fix: adding checks to ensure coin denoms are sorted in `Balance` duri…
mergify[bot] Jan 3, 2022
44d3f4d
fix: register evidence regression (backport #10595) (#10775)
mergify[bot] Jan 3, 2022
a0503e5
fix: Panic if SetOrder* functions forgot modules (backport #10711) (#…
mergify[bot] Jan 3, 2022
0be9863
fix: create query context with requested block height (#10827) (#10866)
mergify[bot] Jan 4, 2022
71a168d
fix: recreate compat field, of null pubkeys in multisig (backport #10…
mergify[bot] Jan 5, 2022
6d44d71
fix!: tx result don't report block gas used as tx gas used (#10833)
yihuang Jan 5, 2022
8932338
feat: support in-place migration ordering (backport #10614) (#10890)
mergify[bot] Jan 6, 2022
05656a2
fix: use full gas on overflow (backport #10897) (#10912)
mergify[bot] Jan 7, 2022
a5c60b7
feat!: x/gov: raise max description length to 10k chars (backport #10…
mergify[bot] Jan 10, 2022
ba1e099
fix: revert tx when block gas limit exceeded (backport: #10770) (#10814)
yihuang Jan 12, 2022
c1c1ad7
chore: v0.45.0 Release Notes (#10760)
amaury1093 Jan 12, 2022
90ffbce
feat: support custom mnemonics in in-process testing network (backpor…
mergify[bot] Jan 13, 2022
8236b26
chore: move server.GenerateCoinKey and server.GenerateSaveCoinKey to …
robert-zaremba Jan 18, 2022
b6c77e6
chore: release v0.45 changelog (#10964)
robert-zaremba Jan 18, 2022
6f7f4fe
Merge tag 'v0.45.0' of https://github.com/cosmos/cosmos-sdk into v0.4…
faddat Feb 3, 2022
c170fe6
v0.45.0
faddat Feb 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: move server.GenerateCoinKey and server.GenerateSaveCoinKey to …
…testutil (cosmos#10956)

* chore: move server.GenerateCoinKey and server.GenerateSaveCoinKey to testutil

* add changelog

* move testutil/known_values.go to testutil/testdata

* changelog
  • Loading branch information
robert-zaremba authored Jan 18, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 8236b26419cda96a5a1491678b227c38e4f533ba
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### API Breaking Changes

* [\#10561](https://github.com/cosmos/cosmos-sdk/pull/10561) The `CommitMultiStore` interface contains a new `SetIAVLCacheSize` method
* [\#10922](https://github.com/cosmos/cosmos-sdk/pull/10922), [/#10956](https://github.com/cosmos/cosmos-sdk/pull/10956) Deprecate key `server.Generate*` functions and move them to `testutil` and support custom mnemonics in in-process testing network. Moved `TestMnemonic` from `testutil` package to `testdata`.

### Features

3 changes: 2 additions & 1 deletion client/keys/add_test.go
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
bip39 "github.com/cosmos/go-bip39"
)
@@ -200,7 +201,7 @@ func Test_runAddCmdDryRun(t *testing.T) {
ctx := context.WithValue(context.Background(), client.ClientContextKey, &clientCtx)

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

t.Cleanup(func() {
3 changes: 2 additions & 1 deletion client/keys/delete_test.go
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
)

@@ -37,7 +38,7 @@ func Test_runDeleteCmd(t *testing.T) {
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn)
require.NoError(t, err)

_, err = kb.NewAccount(fakeKeyName1, testutil.TestMnemonic, "", path, hd.Secp256k1)
_, err = kb.NewAccount(fakeKeyName1, testdata.TestMnemonic, "", path, hd.Secp256k1)
require.NoError(t, err)

_, _, err = kb.NewMnemonic(fakeKeyName2, keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1)
3 changes: 2 additions & 1 deletion client/keys/export_test.go
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"

"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
@@ -91,7 +92,7 @@ func Test_runExportCmd(t *testing.T) {
})

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

clientCtx := client.Context{}.
3 changes: 2 additions & 1 deletion client/keys/list_test.go
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
)

@@ -31,7 +32,7 @@ func Test_runListCmd(t *testing.T) {
ctx := context.WithValue(context.Background(), client.ClientContextKey, &clientCtx)

path := "" //sdk.GetConfig().GetFullBIP44Path()
_, err = kb.NewAccount("something", testutil.TestMnemonic, "", path, hd.Secp256k1)
_, err = kb.NewAccount("something", testdata.TestMnemonic, "", path, hd.Secp256k1)
require.NoError(t, err)

t.Cleanup(func() {
5 changes: 3 additions & 2 deletions client/keys/show_test.go
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
)

@@ -68,11 +69,11 @@ func Test_runShowCmd(t *testing.T) {
})

path := hd.NewFundraiserParams(1, sdk.CoinType, 0).String()
_, err = kb.NewAccount(fakeKeyName1, testutil.TestMnemonic, "", path, hd.Secp256k1)
_, err = kb.NewAccount(fakeKeyName1, testdata.TestMnemonic, "", path, hd.Secp256k1)
require.NoError(t, err)

path2 := hd.NewFundraiserParams(1, sdk.CoinType, 1).String()
_, err = kb.NewAccount(fakeKeyName2, testutil.TestMnemonic, "", path2, hd.Secp256k1)
_, err = kb.NewAccount(fakeKeyName2, testdata.TestMnemonic, "", path2, hd.Secp256k1)
require.NoError(t, err)

// Now try single key
7 changes: 4 additions & 3 deletions crypto/ledger/ledger_mock.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build ledger && test_ledger_mock
// +build ledger,test_ledger_mock

package ledger
@@ -15,7 +16,7 @@ import (

"github.com/cosmos/cosmos-sdk/crypto/hd"
csecp256k1 "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
)

@@ -46,7 +47,7 @@ func (mock LedgerSECP256K1Mock) GetPublicKeySECP256K1(derivationPath []uint32) (
return nil, errors.New("Invalid derivation path")
}

seed, err := bip39.NewSeedWithErrorChecking(testutil.TestMnemonic, "")
seed, err := bip39.NewSeedWithErrorChecking(testdata.TestMnemonic, "")
if err != nil {
return nil, err
}
@@ -88,7 +89,7 @@ func (mock LedgerSECP256K1Mock) GetAddressPubKeySECP256K1(derivationPath []uint3

func (mock LedgerSECP256K1Mock) SignSECP256K1(derivationPath []uint32, message []byte) ([]byte, error) {
path := hd.NewParams(derivationPath[0], derivationPath[1], derivationPath[2], derivationPath[3] != 0, derivationPath[4])
seed, err := bip39.NewSeedWithErrorChecking(testutil.TestMnemonic, "")
seed, err := bip39.NewSeedWithErrorChecking(testdata.TestMnemonic, "")
if err != nil {
return nil, err
}
14 changes: 7 additions & 7 deletions crypto/ledger/ledger_test.go
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
)

@@ -33,11 +33,11 @@ func checkDefaultPubKey(t *testing.T, priv types.LedgerPrivKey) {
expectedPkStr := "PubKeySecp256k1{034FEF9CD7C4C63588D3B03FEB5281B9D232CBA34D6F3D71AEE59211FFBFE1FE87}"
require.Equal(t, "eb5ae98721034fef9cd7c4c63588d3b03feb5281b9d232cba34d6f3d71aee59211ffbfe1fe87",
fmt.Sprintf("%x", cdc.Amino.MustMarshalBinaryBare(priv.PubKey())),
"Is your device using test mnemonic: %s ?", testutil.TestMnemonic)
"Is your device using test mnemonic: %s ?", testdata.TestMnemonic)
require.Equal(t, expectedPkStr, priv.PubKey().String())
addr := sdk.AccAddress(priv.PubKey().Address()).String()
require.Equal(t, "cosmos1w34k53py5v5xyluazqpq65agyajavep2rflq6h",
addr, "Is your device using test mnemonic: %s ?", testutil.TestMnemonic)
addr, "Is your device using test mnemonic: %s ?", testdata.TestMnemonic)
}

func TestPublicKeyUnsafeHDPath(t *testing.T) {
@@ -74,7 +74,7 @@ func TestPublicKeyUnsafeHDPath(t *testing.T) {

// in this test we are chekcking if the generated keys are correct.
require.Equal(t, expectedAnswers[i], priv.PubKey().String(),
"Is your device using test mnemonic: %s ?", testutil.TestMnemonic)
"Is your device using test mnemonic: %s ?", testdata.TestMnemonic)

// Store and restore
serializedPk := priv.Bytes()
@@ -151,7 +151,7 @@ func TestPublicKeyHDPath(t *testing.T) {
require.Equal(t, addr2, addr)
require.Equal(t,
expectedAddrs[i], addr,
"Is your device using test mnemonic: %s ?", testutil.TestMnemonic)
"Is your device using test mnemonic: %s ?", testdata.TestMnemonic)

// Check other methods
tmp := priv.(PrivKeyLedgerSecp256k1)
@@ -161,7 +161,7 @@ func TestPublicKeyHDPath(t *testing.T) {
// in this test we are chekcking if the generated keys are correct and stored in a right path.
require.Equal(t,
expectedPubKeys[i], priv.PubKey().String(),
"Is your device using test mnemonic: %s ?", testutil.TestMnemonic)
"Is your device using test mnemonic: %s ?", testdata.TestMnemonic)

// Store and restore
serializedPk := priv.Bytes()
@@ -203,7 +203,7 @@ func TestSignaturesHD(t *testing.T) {
require.NoError(t, err)

valid := pub.VerifySignature(msg, sig)
require.True(t, valid, "Is your device using test mnemonic: %s ?", testutil.TestMnemonic)
require.True(t, valid, "Is your device using test mnemonic: %s ?", testdata.TestMnemonic)
}
}

42 changes: 11 additions & 31 deletions server/init.go
Original file line number Diff line number Diff line change
@@ -4,14 +4,13 @@ import (
"fmt"

"github.com/cosmos/cosmos-sdk/crypto/keyring"

sdk "github.com/cosmos/cosmos-sdk/types"
)

// GenerateCoinKey returns the address of a public key, along with the secret
// phrase to recover the private key.
// Deprecated: GenerateCoinKey generates a new key mnemonic along with its addrress.
// Please use testutils.GenerateCoinKey instead.
func GenerateCoinKey(algo keyring.SignatureAlgo) (sdk.AccAddress, string, error) {
// generate a private key, with recovery phrase
// generate a private key, with mnemonic
info, secret, err := keyring.NewInMemory().NewMnemonic(
"name",
keyring.English,
@@ -26,11 +25,14 @@ func GenerateCoinKey(algo keyring.SignatureAlgo) (sdk.AccAddress, string, error)
return sdk.AccAddress(info.GetPubKey().Address()), secret, nil
}

// GenerateSaveCoinKey returns the address of a public key, along with the secret
// phrase to recover the private key.
// Deprecated: GenerateSaveCoinKey generates a new key mnemonic with its addrress.
// If mnemonic is provided then it's used for key generation.
// The key is saved in the keyring. The function returns error if overwrite=true and the key
// already exists.
// Please use testutils.GenerateSaveCoinKey instead.
func GenerateSaveCoinKey(
keybase keyring.Keyring,
keyName, mnemonic string,
keyName string,
overwrite bool,
algo keyring.SignatureAlgo,
) (sdk.AccAddress, string, error) {
@@ -52,32 +54,10 @@ func GenerateSaveCoinKey(
}
}

var (
info keyring.Info
secret string
)

if mnemonic != "" {
secret = mnemonic
info, err = keybase.NewAccount(
keyName,
mnemonic,
keyring.DefaultBIP39Passphrase,
sdk.GetConfig().GetFullBIP44Path(),
algo,
)
} else {
info, secret, err = keybase.NewMnemonic(
keyName,
keyring.English,
sdk.GetConfig().GetFullBIP44Path(),
keyring.DefaultBIP39Passphrase,
algo,
)
}
k, mnemonic, err := keybase.NewMnemonic(keyName, keyring.English, sdk.GetConfig().GetFullBIP44Path(), keyring.DefaultBIP39Passphrase, algo)
if err != nil {
return sdk.AccAddress{}, "", err
}

return sdk.AccAddress(info.GetPubKey().Address()), secret, nil
return sdk.AccAddress(k.GetAddress()), mnemonic, nil
}
3 changes: 2 additions & 1 deletion simapp/simd/cmd/testnet.go
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ import (
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/server"
srvconfig "github.com/cosmos/cosmos-sdk/server/config"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
@@ -178,7 +179,7 @@ func InitTestnet(
return err
}

addr, secret, err := server.GenerateSaveCoinKey(kb, nodeDirName, "", true, algo)
addr, secret, err := testutil.GenerateSaveCoinKey(kb, nodeDirName, "", true, algo)
if err != nil {
_ = os.RemoveAll(outputDir)
return err
82 changes: 82 additions & 0 deletions testutil/key.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package testutil

import (
"fmt"

"github.com/cosmos/cosmos-sdk/crypto/keyring"
sdk "github.com/cosmos/cosmos-sdk/types"
)

// GenerateCoinKey generates a new key mnemonic along with its addrress.
func GenerateCoinKey(algo keyring.SignatureAlgo) (sdk.AccAddress, string, error) {
// generate a private key, with mnemonic
info, secret, err := keyring.NewInMemory().NewMnemonic(
"name",
keyring.English,
sdk.GetConfig().GetFullBIP44Path(),
keyring.DefaultBIP39Passphrase,
algo,
)
if err != nil {
return sdk.AccAddress{}, "", err
}

return sdk.AccAddress(info.GetPubKey().Address()), secret, nil
}

// GenerateSaveCoinKey generates a new key mnemonic with its addrress.
// If mnemonic is provided then it's used for key generation.
// The key is saved in the keyring. The function returns error if overwrite=true and the key
// already exists.
func GenerateSaveCoinKey(
keybase keyring.Keyring,
keyName, mnemonic string,
overwrite bool,
algo keyring.SignatureAlgo,
) (sdk.AccAddress, string, error) {
exists := false
_, err := keybase.Key(keyName)
if err == nil {
exists = true
}

// ensure no overwrite
if !overwrite && exists {
return sdk.AccAddress{}, "", fmt.Errorf("key already exists, overwrite is disabled")
}

if exists {
if err := keybase.Delete(keyName); err != nil {
return sdk.AccAddress{}, "", fmt.Errorf("failed to overwrite key")
}
}

var (
info keyring.Info
secret string
)

if mnemonic != "" {
secret = mnemonic
info, err = keybase.NewAccount(
keyName,
mnemonic,
keyring.DefaultBIP39Passphrase,
sdk.GetConfig().GetFullBIP44Path(),
algo,
)
} else {
info, secret, err = keybase.NewMnemonic(
keyName,
keyring.English,
sdk.GetConfig().GetFullBIP44Path(),
keyring.DefaultBIP39Passphrase,
algo,
)
}
if err != nil {
return sdk.AccAddress{}, "", err
}

return sdk.AccAddress(info.GetAddress()), secret, nil
}
Loading