diff --git a/go.mod b/go.mod index ecb7472997..ff9dfe2ba0 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/evmos/ethermint go 1.18 require ( + cosmossdk.io/math v1.0.0-beta.3 github.com/armon/go-metrics v0.4.0 github.com/btcsuite/btcd v0.22.1 github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce @@ -28,7 +29,7 @@ require ( github.com/spf13/cobra v1.5.0 github.com/spf13/viper v1.12.0 github.com/status-im/keycard-go v0.0.0-20200402102358-957c09536969 - github.com/stretchr/testify v1.7.5 + github.com/stretchr/testify v1.8.0 github.com/tendermint/tendermint v0.34.20-0.20220517115723-e6f071164839 github.com/tendermint/tm-db v0.6.7 github.com/tyler-smith/go-bip39 v1.1.0 diff --git a/go.sum b/go.sum index c232619c2d..3f7022a8d6 100644 --- a/go.sum +++ b/go.sum @@ -56,6 +56,8 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE= +cosmossdk.io/math v1.0.0-beta.3 h1:TbZxSopz2LqjJ7aXYfn7nJSb8vNaBklW6BLpcei1qwM= +cosmossdk.io/math v1.0.0-beta.3/go.mod h1:3LYasri3Zna4XpbrTNdKsWmD5fHHkaNAod/mNT9XdE4= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.0.0-beta.2 h1:/BZRNzm8N4K4eWfK28dL4yescorxtO7YG1yun8fy+pI= filippo.io/edwards25519 v1.0.0-beta.2/go.mod h1:X+pm78QAUPtFLi1z9PYIlS/bdDnvbCOGKtZ+ACWEf7o= @@ -1053,8 +1055,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.5 h1:s5PTfem8p8EbKQOctVV53k6jCJt3UX4IEJzwh+C324Q= -github.com/stretchr/testify v1.7.5/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/subosito/gotenv v1.3.0 h1:mjC+YW8QpAdXibNi+vNWgzmgBH4+5l5dCXv8cNysBLI= github.com/subosito/gotenv v1.3.0/go.mod h1:YzJjq/33h7nrwdY+iHMhEOEEbW0ovIz0tB6t6PwAXzs= @@ -1743,4 +1745,5 @@ rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= +sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/rpc/backend/backend.go b/rpc/backend/backend.go index d3c68246f3..b4af0099e9 100644 --- a/rpc/backend/backend.go +++ b/rpc/backend/backend.go @@ -51,7 +51,7 @@ type EVMBackend interface { SetEtherbase(etherbase common.Address) bool ImportRawKey(privkey, password string) (common.Address, error) ListAccounts() ([]common.Address, error) - NewMnemonic(uid string, language keyring.Language, hdPath, bip39Passphrase string, algo keyring.SignatureAlgo) (*keyring.Record, error) + NewMnemonic(uid string, language keyring.Language, hdPath, bip39Passphrase string, algo keyring.SignatureAlgo) (keyring.Info, error) UnprotectedAllowed() bool RPCGasCap() uint64 // global gas cap for eth_call over rpc: DoS protection RPCEVMTimeout() time.Duration // global timeout for eth_call over rpc: DoS protection @@ -158,7 +158,6 @@ func NewBackend(ctx *server.Context, logger log.Logger, clientCtx client.Context viper.GetString(flags.FlagKeyringBackend), clientCtx.KeyringDir, clientCtx.Input, - clientCtx.Codec, hd.EthSecp256k1Option(), ) if err != nil { diff --git a/rpc/backend/backend_suite_test.go b/rpc/backend/backend_suite_test.go index fa7efb0d8b..c977f7176c 100644 --- a/rpc/backend/backend_suite_test.go +++ b/rpc/backend/backend_suite_test.go @@ -137,6 +137,5 @@ func (suite *BackendTestSuite) buildFormattedBlock( func (suite *BackendTestSuite) generateTestKeyring(clientDir string) (keyring.Keyring, error) { buf := bufio.NewReader(os.Stdin) - encCfg := encoding.MakeConfig(app.ModuleBasics) - return keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, clientDir, buf, encCfg.Codec, []keyring.Option{hd.EthSecp256k1Option()}...) + return keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, clientDir, buf, []keyring.Option{hd.EthSecp256k1Option()}...) } diff --git a/rpc/backend/node_info.go b/rpc/backend/node_info.go index 0cc42d8599..a120ee224a 100644 --- a/rpc/backend/node_info.go +++ b/rpc/backend/node_info.go @@ -5,7 +5,6 @@ import ( "math/big" "time" - sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" sdkcrypto "github.com/cosmos/cosmos-sdk/crypto" @@ -34,11 +33,7 @@ func (b *Backend) Accounts() ([]common.Address, error) { } for _, info := range infos { - pubKey, err := info.GetPubKey() - if err != nil { - return nil, err - } - addressBytes := pubKey.Address().Bytes() + addressBytes := info.GetPubKey().Address().Bytes() addresses = append(addresses, common.BytesToAddress(addressBytes)) } @@ -133,7 +128,7 @@ func (b *Backend) SetEtherbase(etherbase common.Address) bool { txFactory = txFactory.WithGas(gas) value := new(big.Int).SetUint64(gas * minGasPriceValue.Ceil().TruncateInt().Uint64()) - fees := sdk.Coins{sdk.NewCoin(denom, sdkmath.NewIntFromBigInt(value))} + fees := sdk.Coins{sdk.NewCoin(denom, sdk.NewIntFromBigInt(value))} builder.SetFeeAmount(fees) builder.SetGasLimit(gas) @@ -143,7 +138,7 @@ func (b *Backend) SetEtherbase(etherbase common.Address) bool { return false } - if err := tx.Sign(txFactory, keyInfo.Name, builder, false); err != nil { + if err := tx.Sign(txFactory, keyInfo.GetName(), builder, false); err != nil { b.logger.Debug("failed to sign tx", "error", err.Error()) return false } @@ -220,18 +215,14 @@ func (b *Backend) ListAccounts() ([]common.Address, error) { } for _, info := range list { - pubKey, err := info.GetPubKey() - if err != nil { - return nil, err - } - addrs = append(addrs, common.BytesToAddress(pubKey.Address())) + addrs = append(addrs, common.BytesToAddress(info.GetPubKey().Address())) } return addrs, nil } // NewAccount will create a new account and returns the address for the new account. -func (b *Backend) NewMnemonic(uid string, language keyring.Language, hdPath, bip39Passphrase string, algo keyring.SignatureAlgo) (*keyring.Record, error) { +func (b *Backend) NewMnemonic(uid string, language keyring.Language, hdPath, bip39Passphrase string, algo keyring.SignatureAlgo) (keyring.Info, error) { info, _, err := b.clientCtx.Keyring.NewMnemonic(uid, keyring.English, bip39Passphrase, bip39Passphrase, algo) if err != nil { return nil, err diff --git a/rpc/backend/tx_info.go b/rpc/backend/tx_info.go index 4de5966144..f3afa1d174 100644 --- a/rpc/backend/tx_info.go +++ b/rpc/backend/tx_info.go @@ -258,7 +258,7 @@ func (b *Backend) GetTransactionReceipt(hash common.Hash) (map[string]interface{ // tolerate the error for pruned node. b.logger.Error("fetch basefee failed, node is pruned?", "height", res.Height, "error", err) } else { - receipt["effectiveGasPrice"] = hexutil.Big(*dynamicTx.EffectiveGasPrice(baseFee)) + receipt["effectiveGasPrice"] = hexutil.Big(*dynamicTx.GetEffectiveGasPrice(baseFee)) } } diff --git a/rpc/namespaces/ethereum/personal/api.go b/rpc/namespaces/ethereum/personal/api.go index 0b9c09ecda..0c4f51b78b 100644 --- a/rpc/namespaces/ethereum/personal/api.go +++ b/rpc/namespaces/ethereum/personal/api.go @@ -90,11 +90,7 @@ func (api *PrivateAccountAPI) NewAccount(password string) (common.Address, error return common.Address{}, err } - pubKey, err := info.GetPubKey() - if err != nil { - return common.Address{}, err - } - addr := common.BytesToAddress(pubKey.Address().Bytes()) + addr := common.BytesToAddress(info.GetPubKey().Address().Bytes()) api.logger.Info("Your new key was generated", "address", addr.String()) api.logger.Info("Please backup your key file!", "path", os.Getenv("HOME")+"/.ethermint/"+name) // TODO: pass the correct binary api.logger.Info("Please remember your password!")