From 81d23cf97a1db64386a6747ca369945ab58e7d71 Mon Sep 17 00:00:00 2001 From: Philip Su Date: Mon, 29 Apr 2024 09:10:59 -0700 Subject: [PATCH 1/4] debug --- x/evm/client/cli/tx.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/x/evm/client/cli/tx.go b/x/evm/client/cli/tx.go index 37844437c8..16d44b1ac6 100644 --- a/x/evm/client/cli/tx.go +++ b/x/evm/client/cli/tx.go @@ -172,8 +172,11 @@ func CmdSend() *cobra.Command { if n, err := cmd.Flags().GetInt64(FlagNonce); err == nil && n >= 0 { nonce = uint64(n) } else { + fmt.Printf("Getting nonce\n") nonce, err = getNonce(rpc, key.PublicKey) + fmt.Printf("Finished getting nonce\n") if err != nil { + fmt.Printf("Get none errord: %s\n", err) return err } } @@ -184,6 +187,7 @@ func CmdSend() *cobra.Command { return fmt.Errorf("%s is an invalid amount to send", args[1]) } txData, err := getTxData(cmd) + fmt.Printf("Finished getting txdata\n") if err != nil { return err } @@ -192,7 +196,9 @@ func CmdSend() *cobra.Command { txData.Data = []byte("") txData.To = &to resp, err := sendTx(txData, rpc, key) + fmt.Printf("Finished send tx\n") if err != nil { + fmt.Printf("Send tx error'd %s\n", err) return err } From e1991e37b5eb4f3d9f2b6594b901c2fd73dbbc7a Mon Sep 17 00:00:00 2001 From: Philip Su Date: Mon, 29 Apr 2024 09:19:22 -0700 Subject: [PATCH 2/4] debug --- x/evm/client/cli/tx.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/x/evm/client/cli/tx.go b/x/evm/client/cli/tx.go index 16d44b1ac6..0d41225a2a 100644 --- a/x/evm/client/cli/tx.go +++ b/x/evm/client/cli/tx.go @@ -172,11 +172,8 @@ func CmdSend() *cobra.Command { if n, err := cmd.Flags().GetInt64(FlagNonce); err == nil && n >= 0 { nonce = uint64(n) } else { - fmt.Printf("Getting nonce\n") nonce, err = getNonce(rpc, key.PublicKey) - fmt.Printf("Finished getting nonce\n") if err != nil { - fmt.Printf("Get none errord: %s\n", err) return err } } @@ -187,7 +184,6 @@ func CmdSend() *cobra.Command { return fmt.Errorf("%s is an invalid amount to send", args[1]) } txData, err := getTxData(cmd) - fmt.Printf("Finished getting txdata\n") if err != nil { return err } @@ -196,9 +192,7 @@ func CmdSend() *cobra.Command { txData.Data = []byte("") txData.To = &to resp, err := sendTx(txData, rpc, key) - fmt.Printf("Finished send tx\n") if err != nil { - fmt.Printf("Send tx error'd %s\n", err) return err } @@ -585,6 +579,7 @@ func getPrivateKey(cmd *cobra.Command) (*ecdsa.PrivateKey, error) { kb := txf.Keybase() info, err := kb.Key(clientCtx.GetFromName()) if err != nil { + fmt.Printf("PSUDEBUG err from kb.key: %s\n", err) return nil, err } localInfo, ok := info.(keyring.LocalInfo) @@ -593,9 +588,11 @@ func getPrivateKey(cmd *cobra.Command) (*ecdsa.PrivateKey, error) { } priv, err := legacy.PrivKeyFromBytes([]byte(localInfo.PrivKeyArmor)) if err != nil { + fmt.Printf("PSUDEBUG err from PrivKeyFromBytes: %s\n", err) return nil, err } privHex := hex.EncodeToString(priv.Bytes()) + fmt.Printf("PSUDEBUG hex to dedcsa\n", err) key, _ := crypto.HexToECDSA(privHex) return key, nil } From 50a497780f790933dd66111904e338befa066233 Mon Sep 17 00:00:00 2001 From: Philip Su Date: Mon, 29 Apr 2024 09:24:10 -0700 Subject: [PATCH 3/4] debug --- evmrpc/utils.go | 5 +++++ x/evm/client/cli/tx.go | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/evmrpc/utils.go b/evmrpc/utils.go index 0e7a974129..0f2bfc5149 100644 --- a/evmrpc/utils.go +++ b/evmrpc/utils.go @@ -5,6 +5,7 @@ import ( "crypto/ecdsa" "encoding/hex" "fmt" + "github.com/cosmos/cosmos-sdk/crypto/hd" "math/big" "time" @@ -197,6 +198,10 @@ func getAddressPrivKeyMap(kb keyring.Keyring) map[string]*ecdsa.PrivateKey { // will only show local key continue } + if localInfo.GetAlgo() != hd.Secp256k1Type { + fmt.Printf("Skipping address %s because it isn't signed with secp256k1\n", localInfo.Name) + continue + } priv, err := legacy.PrivKeyFromBytes([]byte(localInfo.PrivKeyArmor)) if err != nil { continue diff --git a/x/evm/client/cli/tx.go b/x/evm/client/cli/tx.go index 0d41225a2a..3d7b8d72fb 100644 --- a/x/evm/client/cli/tx.go +++ b/x/evm/client/cli/tx.go @@ -7,6 +7,7 @@ import ( "encoding/json" "errors" "fmt" + "github.com/cosmos/cosmos-sdk/crypto/hd" "io" "math/big" "net/http" @@ -95,6 +96,9 @@ func CmdAssociateAddress() *cobra.Command { if !ok { return errors.New("can only associate address for local keys") } + if localInfo.GetAlgo() != hd.Secp256k1Type { + return errors.New("can only use addresses using secp256k1") + } priv, err := legacy.PrivKeyFromBytes([]byte(localInfo.PrivKeyArmor)) if err != nil { return err @@ -579,20 +583,20 @@ func getPrivateKey(cmd *cobra.Command) (*ecdsa.PrivateKey, error) { kb := txf.Keybase() info, err := kb.Key(clientCtx.GetFromName()) if err != nil { - fmt.Printf("PSUDEBUG err from kb.key: %s\n", err) return nil, err } localInfo, ok := info.(keyring.LocalInfo) if !ok { return nil, errors.New("can only associate address for local keys") } + if localInfo.GetAlgo() != hd.Secp256k1Type { + return nil, errors.New("can only use addresses using secp256k1") + } priv, err := legacy.PrivKeyFromBytes([]byte(localInfo.PrivKeyArmor)) if err != nil { - fmt.Printf("PSUDEBUG err from PrivKeyFromBytes: %s\n", err) return nil, err } privHex := hex.EncodeToString(priv.Bytes()) - fmt.Printf("PSUDEBUG hex to dedcsa\n", err) key, _ := crypto.HexToECDSA(privHex) return key, nil } From b7da4363ce05da9d83582993fa09b88318f45821 Mon Sep 17 00:00:00 2001 From: Philip Su Date: Mon, 29 Apr 2024 10:39:38 -0700 Subject: [PATCH 4/4] goimport --- evmrpc/utils.go | 3 ++- x/evm/client/cli/tx.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/evmrpc/utils.go b/evmrpc/utils.go index 0f2bfc5149..f39bf9b3c5 100644 --- a/evmrpc/utils.go +++ b/evmrpc/utils.go @@ -5,10 +5,11 @@ import ( "crypto/ecdsa" "encoding/hex" "fmt" - "github.com/cosmos/cosmos-sdk/crypto/hd" "math/big" "time" + "github.com/cosmos/cosmos-sdk/crypto/hd" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/config" "github.com/cosmos/cosmos-sdk/codec/legacy" diff --git a/x/evm/client/cli/tx.go b/x/evm/client/cli/tx.go index 3d7b8d72fb..93e52710de 100644 --- a/x/evm/client/cli/tx.go +++ b/x/evm/client/cli/tx.go @@ -7,7 +7,6 @@ import ( "encoding/json" "errors" "fmt" - "github.com/cosmos/cosmos-sdk/crypto/hd" "io" "math/big" "net/http" @@ -15,6 +14,8 @@ import ( "strconv" "strings" + "github.com/cosmos/cosmos-sdk/crypto/hd" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/crypto"