Skip to content

Commit e2f6e47

Browse files
mmsqealjo242
andauthored
fix: allow ledger flag work with coin type 60 (backport: 690) (#836)
* fix: allow ledger flag work with coin type 60 (#690) * fix: allow ledger flag work with coin type 60 aligned ledger firmware with go-ethereum * lint * allow to generate both * cleanup * fix test * fix build * fix resolve --------- Co-authored-by: Alex | Cosmos Labs <[email protected]> * bump sdk to v0.53.x --------- Co-authored-by: Alex | Cosmos Labs <[email protected]>
1 parent 588c8df commit e2f6e47

File tree

10 files changed

+409
-373
lines changed

10 files changed

+409
-373
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
### BUG FIXES
1212

13+
- [\#690](https://github.com/cosmos/evm/pull/690) Fix Ledger hardware wallet support for coin type 60.
1314
- [\#769](https://github.com/cosmos/evm/pull/769) Fix erc20 ibc middleware to not to validate sender address format.
1415
- [\#790](https://github.com/cosmos/evm/pull/790) fix panic in historical query due to missing EvmCoinInfo.
1516
- [\#816](https://github.com/cosmos/evm/pull/816) Avoid nil pointer when RPC requests execute before evmCoinInfo initialization in PreBlock with defaultEvmCoinInfo fallback.

client/keys/add.go

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"bytes"
66
"encoding/json"
77
"errors"
8+
"flag"
89
"fmt"
910
"io"
1011
"os"
@@ -13,7 +14,9 @@ import (
1314
"github.com/spf13/cobra"
1415

1516
cryptohd "github.com/cosmos/evm/crypto/hd"
17+
evmkeyring "github.com/cosmos/evm/crypto/keyring"
1618
bip39 "github.com/cosmos/go-bip39"
19+
ledger "github.com/cosmos/ledger-cosmos-go"
1720

1821
"github.com/cosmos/cosmos-sdk/client"
1922
"github.com/cosmos/cosmos-sdk/client/flags"
@@ -22,6 +25,8 @@ import (
2225
"github.com/cosmos/cosmos-sdk/crypto/hd"
2326
"github.com/cosmos/cosmos-sdk/crypto/keyring"
2427
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
28+
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
29+
cosmosLedger "github.com/cosmos/cosmos-sdk/crypto/ledger"
2530
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
2631
sdk "github.com/cosmos/cosmos-sdk/types"
2732
)
@@ -172,7 +177,37 @@ func RunAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *buf
172177
// If we're using ledger, only thing we need is the path and the bech32 prefix.
173178
if useLedger {
174179
bech32PrefixAccAddr := sdk.GetConfig().GetBech32AccountAddrPrefix()
175-
180+
needHardware := flag.Lookup("test.v") == nil && os.Getenv("GO_TEST") != "1"
181+
if needHardware {
182+
switch coinType {
183+
case 60:
184+
cosmosLedger.SetDiscoverLedger(func() (cosmosLedger.SECP256K1, error) {
185+
return evmkeyring.LedgerDerivation()
186+
})
187+
cosmosLedger.SetCreatePubkey(func(key []byte) cryptotypes.PubKey {
188+
return evmkeyring.CreatePubkey(key)
189+
})
190+
cosmosLedger.SetAppName(evmkeyring.AppName)
191+
cosmosLedger.SetDERConversion(false)
192+
case 118:
193+
cosmosLedger.SetDiscoverLedger(func() (cosmosLedger.SECP256K1, error) {
194+
device, err := ledger.FindLedgerCosmosUserApp()
195+
if err != nil {
196+
return nil, err
197+
}
198+
return device, nil
199+
})
200+
cosmosLedger.SetCreatePubkey(func(key []byte) cryptotypes.PubKey {
201+
return &secp256k1.PubKey{Key: key}
202+
})
203+
cosmosLedger.SetAppName(cosmosLedger.AppName)
204+
cosmosLedger.SetDERConversion(true)
205+
default:
206+
return fmt.Errorf(
207+
"unsupported coin type %d for Ledger. Supported coin types: 60 (Ethereum app), 118 (Cosmos app)", coinType,
208+
)
209+
}
210+
}
176211
// use the provided algo to save the ledger key
177212
k, err := kb.SaveLedgerKey(name, algo, bech32PrefixAccAddr, coinType, account, index)
178213
if err != nil {

evmd/cmd/evmd/cmd/root.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ package cmd
22

33
import (
44
"errors"
5-
"github.com/cosmos/evm/x/vm/types"
65
"io"
76
"os"
87

8+
"github.com/cosmos/evm/x/vm/types"
9+
910
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
1011
"github.com/spf13/cast"
1112
"github.com/spf13/cobra"
@@ -18,7 +19,7 @@ import (
1819
cosmosevmcmd "github.com/cosmos/evm/client"
1920
evmdebug "github.com/cosmos/evm/client/debug"
2021
"github.com/cosmos/evm/config"
21-
cosmosevmkeyring "github.com/cosmos/evm/crypto/keyring"
22+
"github.com/cosmos/evm/crypto/hd"
2223
"github.com/cosmos/evm/evmd"
2324
cosmosevmserver "github.com/cosmos/evm/server"
2425
srvflags "github.com/cosmos/evm/server/flags"
@@ -80,7 +81,7 @@ func NewRootCmd() *cobra.Command {
8081
WithHomeDir(config.MustGetDefaultNodeHome()).
8182
WithViper(""). // In simapp, we don't use any prefix for env variables.
8283
// Cosmos EVM specific setup
83-
WithKeyringOptions(cosmosevmkeyring.Option()).
84+
WithKeyringOptions(hd.EthSecp256k1Option()).
8485
WithLedgerHasProtobuf(true)
8586

8687
rootCmd := &cobra.Command{

evmd/go.mod

Lines changed: 51 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ require (
1414
cosmossdk.io/x/evidence v0.2.0
1515
cosmossdk.io/x/feegrant v0.2.0
1616
cosmossdk.io/x/upgrade v0.2.0
17-
github.com/cometbft/cometbft v0.38.18
17+
github.com/cometbft/cometbft v0.38.19
1818
github.com/cosmos/cosmos-db v1.1.3
19-
github.com/cosmos/cosmos-sdk v0.53.4
19+
github.com/cosmos/cosmos-sdk v0.53.5-0.20251030204916-768cb210885c
2020
github.com/cosmos/evm v0.2.0
21-
github.com/cosmos/gogoproto v1.7.0
21+
github.com/cosmos/gogoproto v1.7.2
2222
github.com/cosmos/ibc-go/v10 v10.3.1-0.20250909102629-ed3b125c7b6f
2323
github.com/ethereum/go-ethereum v1.15.11
2424
github.com/onsi/ginkgo/v2 v2.23.4
2525
github.com/onsi/gomega v1.38.0
26-
github.com/spf13/cast v1.9.2
26+
github.com/spf13/cast v1.10.0
2727
github.com/spf13/cobra v1.10.1
28-
github.com/spf13/pflag v1.0.9
28+
github.com/spf13/pflag v1.0.10
2929
github.com/spf13/viper v1.20.1
3030
github.com/stretchr/testify v1.11.1
3131
golang.org/x/sync v0.16.0
@@ -34,14 +34,14 @@ require (
3434

3535
require (
3636
cel.dev/expr v0.24.0 // indirect
37-
cloud.google.com/go v0.116.0 // indirect
38-
cloud.google.com/go/auth v0.14.1 // indirect
39-
cloud.google.com/go/auth/oauth2adapt v0.2.7 // indirect
40-
cloud.google.com/go/compute/metadata v0.7.0 // indirect
41-
cloud.google.com/go/iam v1.2.2 // indirect
42-
cloud.google.com/go/monitoring v1.21.2 // indirect
43-
cloud.google.com/go/storage v1.49.0 // indirect
44-
cosmossdk.io/collections v1.2.1 // indirect
37+
cloud.google.com/go v0.120.0 // indirect
38+
cloud.google.com/go/auth v0.16.4 // indirect
39+
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
40+
cloud.google.com/go/compute/metadata v0.8.0 // indirect
41+
cloud.google.com/go/iam v1.5.2 // indirect
42+
cloud.google.com/go/monitoring v1.24.2 // indirect
43+
cloud.google.com/go/storage v1.50.0 // indirect
44+
cosmossdk.io/collections v1.3.1 // indirect
4545
cosmossdk.io/depinject v1.2.1 // indirect
4646
cosmossdk.io/schema v1.1.0 // indirect
4747
cosmossdk.io/x/tx v0.14.0 // indirect
@@ -51,26 +51,26 @@ require (
5151
github.com/DataDog/datadog-go v4.8.3+incompatible // indirect
5252
github.com/DataDog/zstd v1.5.7 // indirect
5353
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.29.0 // indirect
54-
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.48.1 // indirect
55-
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.48.1 // indirect
54+
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.50.0 // indirect
55+
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.50.0 // indirect
5656
github.com/Microsoft/go-winio v0.6.2 // indirect
57-
github.com/StackExchange/wmi v1.2.1 // indirect
5857
github.com/VictoriaMetrics/fastcache v1.12.2 // indirect
5958
github.com/aws/aws-sdk-go v1.49.0 // indirect
6059
github.com/beorn7/perks v1.0.1 // indirect
6160
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
6261
github.com/bgentry/speakeasy v0.2.0 // indirect
63-
github.com/bits-and-blooms/bitset v1.22.0 // indirect
62+
github.com/bits-and-blooms/bitset v1.24.3 // indirect
6463
github.com/btcsuite/btcd v0.24.2 // indirect
65-
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
64+
github.com/btcsuite/btcd/btcec/v2 v2.3.5 // indirect
6665
github.com/btcsuite/btcd/btcutil v1.1.6 // indirect
6766
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
68-
github.com/bytedance/sonic v1.14.0 // indirect
69-
github.com/bytedance/sonic/loader v0.3.0 // indirect
67+
github.com/bytedance/gopkg v0.1.3 // indirect
68+
github.com/bytedance/sonic v1.14.2 // indirect
69+
github.com/bytedance/sonic/loader v0.4.0 // indirect
7070
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
7171
github.com/cespare/xxhash/v2 v2.3.0 // indirect
7272
github.com/chzyer/readline v1.5.1 // indirect
73-
github.com/cloudwego/base64x v0.1.5 // indirect
73+
github.com/cloudwego/base64x v0.1.6 // indirect
7474
github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443 // indirect
7575
github.com/cockroachdb/apd/v2 v2.0.2 // indirect
7676
github.com/cockroachdb/errors v1.12.0 // indirect
@@ -87,7 +87,7 @@ require (
8787
github.com/cosmos/gogogateway v1.2.0 // indirect
8888
github.com/cosmos/iavl v1.2.2 // indirect
8989
github.com/cosmos/ics23/go v0.11.0 // indirect
90-
github.com/cosmos/ledger-cosmos-go v0.14.0 // indirect
90+
github.com/cosmos/ledger-cosmos-go v0.16.0 // indirect
9191
github.com/crate-crypto/go-eth-kzg v1.3.0 // indirect
9292
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect
9393
github.com/creachadair/atomicfile v0.3.7 // indirect
@@ -98,7 +98,7 @@ require (
9898
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
9999
github.com/desertbit/timer v1.0.1 // indirect
100100
github.com/dgraph-io/badger/v4 v4.2.0 // indirect
101-
github.com/dgraph-io/ristretto v0.1.1 // indirect
101+
github.com/dgraph-io/ristretto v0.2.0 // indirect
102102
github.com/dlclark/regexp2 v1.7.0 // indirect
103103
github.com/dop251/goja v0.0.0-20230605162241-28ee0ee714f3 // indirect
104104
github.com/dustin/go-humanize v1.0.1 // indirect
@@ -112,7 +112,7 @@ require (
112112
github.com/felixge/httpsnoop v1.0.4 // indirect
113113
github.com/ferranbt/fastssz v0.1.4 // indirect
114114
github.com/fsnotify/fsnotify v1.9.0 // indirect
115-
github.com/getsentry/sentry-go v0.32.0 // indirect
115+
github.com/getsentry/sentry-go v0.35.0 // indirect
116116
github.com/go-jose/go-jose/v4 v4.1.1 // indirect
117117
github.com/go-kit/kit v0.13.0 // indirect
118118
github.com/go-kit/log v0.2.1 // indirect
@@ -122,13 +122,12 @@ require (
122122
github.com/go-ole/go-ole v1.3.0 // indirect
123123
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
124124
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
125-
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
125+
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
126126
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
127127
github.com/gofrs/flock v0.12.1 // indirect
128128
github.com/gogo/googleapis v1.4.1 // indirect
129129
github.com/gogo/protobuf v1.3.2 // indirect
130-
github.com/golang/glog v1.2.5 // indirect
131-
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
130+
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
132131
github.com/golang/protobuf v1.5.4 // indirect
133132
github.com/golang/snappy v0.0.5-0.20231225225746-43d5d4cd4e0e // indirect
134133
github.com/google/btree v1.1.3 // indirect
@@ -138,8 +137,8 @@ require (
138137
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect
139138
github.com/google/s2a-go v0.1.9 // indirect
140139
github.com/google/uuid v1.6.0 // indirect
141-
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
142-
github.com/googleapis/gax-go/v2 v2.14.1 // indirect
140+
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
141+
github.com/googleapis/gax-go/v2 v2.15.0 // indirect
143142
github.com/gorilla/handlers v1.5.2 // indirect
144143
github.com/gorilla/mux v1.8.1 // indirect
145144
github.com/gorilla/websocket v1.5.3 // indirect
@@ -153,7 +152,7 @@ require (
153152
github.com/hashicorp/go-metrics v0.5.4 // indirect
154153
github.com/hashicorp/go-plugin v1.6.3 // indirect
155154
github.com/hashicorp/go-safetemp v1.0.0 // indirect
156-
github.com/hashicorp/go-version v1.6.0 // indirect
155+
github.com/hashicorp/go-version v1.7.0 // indirect
157156
github.com/hashicorp/golang-lru v1.0.2 // indirect
158157
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
159158
github.com/hashicorp/yamux v0.1.2 // indirect
@@ -199,20 +198,20 @@ require (
199198
github.com/pkg/errors v0.9.1 // indirect
200199
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
201200
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
202-
github.com/prometheus/client_golang v1.22.0 // indirect
203-
github.com/prometheus/client_model v0.6.1 // indirect
204-
github.com/prometheus/common v0.63.0 // indirect
205-
github.com/prometheus/procfs v0.15.1 // indirect
201+
github.com/prometheus/client_golang v1.23.0 // indirect
202+
github.com/prometheus/client_model v0.6.2 // indirect
203+
github.com/prometheus/common v0.65.0 // indirect
204+
github.com/prometheus/procfs v0.16.1 // indirect
206205
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
207206
github.com/rivo/uniseg v0.2.0 // indirect
208207
github.com/rogpeppe/go-internal v1.14.1 // indirect
209208
github.com/rs/cors v1.11.1 // indirect
210209
github.com/rs/zerolog v1.34.0 // indirect
211-
github.com/sagikazarmark/locafero v0.7.0 // indirect
210+
github.com/sagikazarmark/locafero v0.9.0 // indirect
212211
github.com/sasha-s/go-deadlock v0.3.5 // indirect
213-
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
212+
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
214213
github.com/sourcegraph/conc v0.3.0 // indirect
215-
github.com/spf13/afero v1.12.0 // indirect
214+
github.com/spf13/afero v1.14.0 // indirect
216215
github.com/spiffe/go-spiffe/v2 v2.5.0 // indirect
217216
github.com/stretchr/objx v0.5.2 // indirect
218217
github.com/subosito/gotenv v1.6.0 // indirect
@@ -224,28 +223,31 @@ require (
224223
github.com/tidwall/match v1.1.1 // indirect
225224
github.com/tidwall/pretty v1.2.0 // indirect
226225
github.com/tidwall/sjson v1.2.5 // indirect
227-
github.com/tklauser/go-sysconf v0.3.12 // indirect
228-
github.com/tklauser/numcpus v0.6.1 // indirect
226+
github.com/tklauser/go-sysconf v0.3.15 // indirect
227+
github.com/tklauser/numcpus v0.10.0 // indirect
229228
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
230229
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
231230
github.com/ulikunitz/xz v0.5.11 // indirect
231+
github.com/yusufpapurcu/wmi v1.2.4 // indirect
232232
github.com/zeebo/errs v1.4.0 // indirect
233+
github.com/zondax/golem v0.27.0 // indirect
233234
github.com/zondax/hid v0.9.2 // indirect
234-
github.com/zondax/ledger-go v0.14.3 // indirect
235+
github.com/zondax/ledger-go v1.0.1 // indirect
235236
go.etcd.io/bbolt v1.4.0-alpha.1 // indirect
236237
go.opencensus.io v0.24.0 // indirect
237238
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
238239
go.opentelemetry.io/contrib/detectors/gcp v1.36.0 // indirect
239-
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.58.0 // indirect
240-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0 // indirect
240+
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0 // indirect
241+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.62.0 // indirect
241242
go.opentelemetry.io/otel v1.37.0 // indirect
242243
go.opentelemetry.io/otel/metric v1.37.0 // indirect
243244
go.opentelemetry.io/otel/sdk v1.37.0 // indirect
244245
go.opentelemetry.io/otel/sdk/metric v1.37.0 // indirect
245246
go.opentelemetry.io/otel/trace v1.37.0 // indirect
246247
go.uber.org/automaxprocs v1.6.0 // indirect
247-
go.uber.org/mock v0.5.2 // indirect
248+
go.uber.org/mock v0.6.0 // indirect
248249
go.uber.org/multierr v1.11.0 // indirect
250+
go.uber.org/zap v1.27.0 // indirect
249251
go.yaml.in/yaml/v2 v2.4.2 // indirect
250252
golang.org/x/arch v0.17.0 // indirect
251253
golang.org/x/crypto v0.41.0 // indirect
@@ -255,13 +257,13 @@ require (
255257
golang.org/x/sys v0.35.0 // indirect
256258
golang.org/x/term v0.34.0 // indirect
257259
golang.org/x/text v0.28.0 // indirect
258-
golang.org/x/time v0.10.0 // indirect
259-
golang.org/x/tools v0.35.0 // indirect
260-
google.golang.org/api v0.222.0 // indirect
261-
google.golang.org/genproto v0.0.0-20241118233622-e639e219e697 // indirect
260+
golang.org/x/time v0.12.0 // indirect
261+
golang.org/x/tools v0.36.0 // indirect
262+
google.golang.org/api v0.247.0 // indirect
263+
google.golang.org/genproto v0.0.0-20250603155806-513f23925822 // indirect
262264
google.golang.org/genproto/googleapis/api v0.0.0-20250707201910-8d1bb00bc6a7 // indirect
263-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250707201910-8d1bb00bc6a7 // indirect
264-
google.golang.org/protobuf v1.36.8 // indirect
265+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250818200422-3122310a409c // indirect
266+
google.golang.org/protobuf v1.36.10 // indirect
265267
gopkg.in/yaml.v2 v2.4.0 // indirect
266268
gopkg.in/yaml.v3 v3.0.1 // indirect
267269
gotest.tools/v3 v3.5.2 // indirect

0 commit comments

Comments
 (0)