bump SDK to v0.39.1 (#386)

* bump sdk version to v0.39.0 candidate

* updates

* update evm

* bump commit

* more changes

* build

* genesis

* fix tests

* fix tests

* bump commit

* bump commit

* bump commit

* add keygen func

* bump version to 0.39.0-rc0

* update AnteHandler

* fix TxDecoder

* lint

* fix test

* update statedb

* changelog

* fixes

* remove extra files

* update make test-import

* rename test

* bump SDK version to final release

* update to 0.39.1-rc1

* fix evm tests

* update RPC

* minor fixes

* update to rc2

* bump to v0.39.1

* fix personal API

* fix string type cast ambiguity (#449)

* init

* fix estimate gas test

* minor genesis change

* remove comments from unstable commit (stargate release)

Co-authored-by: Alessio Treglia <quadrispro@ubuntu.com>
This commit is contained in:
Federico Kunze
2020-08-23 17:41:54 -04:00
committed by GitHub
co-authored by Alessio Treglia
parent 6fa5fafb12
commit 261f86fdf2
65 changed files with 688 additions and 2696 deletions
+15 -15
View File
@@ -14,43 +14,43 @@ import (
tmcrypto "github.com/tendermint/tendermint/crypto"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys"
)
const (
// EthSecp256k1 defines the ECDSA secp256k1 used on Ethereum
EthSecp256k1 = keyring.SigningAlgo("eth_secp256k1")
EthSecp256k1 = keys.SigningAlgo("eth_secp256k1")
)
// SupportedAlgorithms defines the list of signing algorithms used on Ethermint:
// - eth_secp256k1 (Ethereum)
// - secp256k1 (Tendermint)
var SupportedAlgorithms = []keyring.SigningAlgo{EthSecp256k1, keyring.Secp256k1}
var SupportedAlgorithms = []keys.SigningAlgo{EthSecp256k1, keys.Secp256k1}
// EthSecp256k1Options defines a keyring options for the ethereum Secp256k1 curve.
func EthSecp256k1Options() []keyring.KeybaseOption {
return []keyring.KeybaseOption{
keyring.WithKeygenFunc(EthermintKeygenFunc),
keyring.WithDeriveFunc(DeriveKey),
keyring.WithSupportedAlgos(SupportedAlgorithms),
keyring.WithSupportedAlgosLedger(SupportedAlgorithms),
// EthSecp256k1Options defines a keys options for the ethereum Secp256k1 curve.
func EthSecp256k1Options() []keys.KeybaseOption {
return []keys.KeybaseOption{
keys.WithKeygenFunc(EthermintKeygenFunc),
keys.WithDeriveFunc(DeriveKey),
keys.WithSupportedAlgos(SupportedAlgorithms),
keys.WithSupportedAlgosLedger(SupportedAlgorithms),
}
}
func DeriveKey(mnemonic, bip39Passphrase, hdPath string, algo keyring.SigningAlgo) ([]byte, error) {
func DeriveKey(mnemonic, bip39Passphrase, hdPath string, algo keys.SigningAlgo) ([]byte, error) {
switch algo {
case keyring.Secp256k1:
return keyring.StdDeriveKey(mnemonic, bip39Passphrase, hdPath, algo)
case keys.Secp256k1:
return keys.StdDeriveKey(mnemonic, bip39Passphrase, hdPath, algo)
case EthSecp256k1:
return DeriveSecp256k1(mnemonic, bip39Passphrase, hdPath)
default:
return nil, errors.Wrap(keyring.ErrUnsupportedSigningAlgo, string(algo))
return nil, errors.Wrap(keys.ErrUnsupportedSigningAlgo, string(algo))
}
}
// EthermintKeygenFunc is the key generation function to generate secp256k1 ToECDSA
// from ethereum.
func EthermintKeygenFunc(bz []byte, algo keyring.SigningAlgo) (tmcrypto.PrivKey, error) {
func EthermintKeygenFunc(bz []byte, algo keys.SigningAlgo) (tmcrypto.PrivKey, error) {
if algo != EthSecp256k1 {
return nil, fmt.Errorf("signing algorithm must be %s, got %s", EthSecp256k1, algo)
}
+8 -8
View File
@@ -8,7 +8,7 @@ import (
ethcrypto "github.com/ethereum/go-ethereum/crypto"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys"
"github.com/cosmos/cosmos-sdk/crypto/keys/hd"
"github.com/cosmos/cosmos-sdk/tests"
sdk "github.com/cosmos/cosmos-sdk/types"
@@ -21,7 +21,7 @@ func TestEthermintKeygenFunc(t *testing.T) {
testCases := []struct {
name string
privKey []byte
algo keyring.SigningAlgo
algo keys.SigningAlgo
expPass bool
}{
{
@@ -45,7 +45,7 @@ func TestEthermintKeygenFunc(t *testing.T) {
{
"invalid algo",
nil,
keyring.MultiAlgo,
keys.MultiAlgo,
false,
},
}
@@ -66,7 +66,7 @@ func TestKeyring(t *testing.T) {
mockIn := strings.NewReader("")
t.Cleanup(cleanup)
kr, err := keyring.NewKeyring("ethermint", keyring.BackendTest, dir, mockIn, EthSecp256k1Options()...)
kr, err := keys.NewKeyring("ethermint", keys.BackendTest, dir, mockIn, EthSecp256k1Options()...)
require.NoError(t, err)
// fail in retrieving key
@@ -75,7 +75,7 @@ func TestKeyring(t *testing.T) {
require.Nil(t, info)
mockIn.Reset("password\npassword\n")
info, mnemonic, err := kr.CreateMnemonic("foo", keyring.English, sdk.FullFundraiserPath, EthSecp256k1)
info, mnemonic, err := kr.CreateMnemonic("foo", keys.English, sdk.FullFundraiserPath, EthSecp256k1)
require.NoError(t, err)
require.NotEmpty(t, mnemonic)
require.Equal(t, "foo", info.GetName())
@@ -85,15 +85,15 @@ func TestKeyring(t *testing.T) {
params := *hd.NewFundraiserParams(0, sdk.CoinType, 0)
hdPath := params.String()
bz, err := DeriveKey(mnemonic, keyring.DefaultBIP39Passphrase, hdPath, EthSecp256k1)
bz, err := DeriveKey(mnemonic, keys.DefaultBIP39Passphrase, hdPath, EthSecp256k1)
require.NoError(t, err)
require.NotEmpty(t, bz)
bz, err = DeriveKey(mnemonic, keyring.DefaultBIP39Passphrase, hdPath, keyring.Secp256k1)
bz, err = DeriveKey(mnemonic, keys.DefaultBIP39Passphrase, hdPath, keys.Secp256k1)
require.NoError(t, err)
require.NotEmpty(t, bz)
bz, err = DeriveKey(mnemonic, keyring.DefaultBIP39Passphrase, hdPath, keyring.SigningAlgo(""))
bz, err = DeriveKey(mnemonic, keys.DefaultBIP39Passphrase, hdPath, keys.SigningAlgo(""))
require.Error(t, err)
require.Empty(t, bz)
}
+3 -3
View File
@@ -4,7 +4,7 @@ import (
cryptoamino "github.com/tendermint/tendermint/crypto/encoding/amino"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys"
)
// CryptoCodec is the default amino codec used by ethermint
@@ -19,8 +19,8 @@ const (
func init() {
// replace the keyring codec with the ethermint crypto codec to prevent
// amino panics because of unregistered Priv/PubKey
keyring.CryptoCdc = CryptoCodec
keyring.RegisterCodec(CryptoCodec)
keys.CryptoCdc = CryptoCodec
keys.RegisterCodec(CryptoCodec)
cryptoamino.RegisterAmino(CryptoCodec)
RegisterCodec(CryptoCodec)
}
-7
View File
@@ -7,16 +7,9 @@ import (
ethcrypto "github.com/ethereum/go-ethereum/crypto"
ethsecp256k1 "github.com/ethereum/go-ethereum/crypto/secp256k1"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
tmcrypto "github.com/tendermint/tendermint/crypto"
)
func init() {
authtypes.RegisterKeyTypeCodec(PubKeySecp256k1{}, PubKeyAminoName)
authtypes.RegisterKeyTypeCodec(PrivKeySecp256k1{}, PrivKeyAminoName)
}
// ----------------------------------------------------------------------------
// secp256k1 Private Key