obsidiansystems / ledger-app-tezos

Ledger app for Tezos
Apache License 2.0
102 stars 51 forks source link

Inconsistent detection of Ledger on macOS 10.14 #30

Closed atyndall closed 4 years ago

atyndall commented 5 years ago

There seems to be some sort of bug with tezos-client (commit d06e9b1b) and the Ledger app, whereby I am getting inconsistent detection on macOS 10.14. What will usually occur is I load the Tezos app (latest, 1.4.0, downloaded from Ledger Live) on the Ledger, and the first command (listing/signing transaction/etc) will fail, a few seconds later the same command will work, and then after that the command will fail consistently for a while, until I close and reopen the Ledger app on my Ledger Nano S, or wait a while.

Let me know what additional debugging info you require. I can post the logs with export TEZOS_LOG="client.signer.ledger -> debug", but I'd like to know if that contains any confidential info I should redact first.

➜  tezos git:(mainnet) ✗ tezos-client list connected ledgers
Disclaimer:
  The  Tezos  network  is  a  new  blockchain technology.
  Users are  solely responsible  for any risks associated
  with usage of the Tezos network.  Users should do their
  own  research to determine  if Tezos is the appropriate
  platform for their needs and should apply judgement and
  care in their network interactions.

Nov 18 16:41:47 - client.signer.ledger: WARNING: The device at [USB_<IDENTIFIER>] is not a Tezos application
Nov 18 16:41:47 - client.signer.ledger: APDU level error: Unexpected sequence number (expected 0, got 191)
No device found.
Make sure a Ledger Nano S is connected and in the Tezos Wallet app.
Nov 18 16:41:47 - client.signer.ledger: WARNING: The device at [USB_<IDENTIFIER>] is not a Tezos application
Nov 18 16:41:47 - client.signer.ledger: APDU level error: Unexpected sequence number (expected 0, got 191)
➜  tezos git:(mainnet) ✗ tezos-client list connected ledgers
Disclaimer:
  The  Tezos  network  is  a  new  blockchain technology.
  Users are  solely responsible  for any risks associated
  with usage of the Tezos network.  Users should do their
  own  research to determine  if Tezos is the appropriate
  platform for their needs and should apply judgement and
  care in their network interactions.

Found a Tezos Wallet 1.4.0 (commit 0954efc8) application running on Ledger Nano S at [USB_<IDENTIFIER>].

To use keys at BIP32 path m/44'/1729'/0'/0' (default Tezos key path), use one of
 tezos-client import secret key ledger_atyndall "ledger://<IDENTIFIER>/ed25519/0'/0'"
 tezos-client import secret key ledger_atyndall "ledger://<IDENTIFIER>/secp256k1/0'/0'"
 tezos-client import secret key ledger_atyndall "ledger://<IDENTIFIER>/P-256/0'/0'"
Found a Tezos Wallet 1.4.0 (commit 0954efc8) application running on Ledger Nano S at [USB_<IDENTIFIER>].

To use keys at BIP32 path m/44'/1729'/0'/0' (default Tezos key path), use one of
 tezos-client import secret key ledger_atyndall "ledger://<IDENTIFIER>/ed25519/0'/0'"
 tezos-client import secret key ledger_atyndall "ledger://<IDENTIFIER>/secp256k1/0'/0'"
 tezos-client import secret key ledger_atyndall "ledger://<IDENTIFIER>/P-256/0'/0'"
➜  tezos git:(mainnet) ✗ tezos-client list connected ledgers
Disclaimer:
  The  Tezos  network  is  a  new  blockchain technology.
  Users are  solely responsible  for any risks associated
  with usage of the Tezos network.  Users should do their
  own  research to determine  if Tezos is the appropriate
  platform for their needs and should apply judgement and
  care in their network interactions.

Nov 18 16:41:53 - client.signer.ledger: WARNING: The device at [USB_<IDENTIFIER>] is not a Tezos application
Nov 18 16:41:53 - client.signer.ledger: APDU level error: Unexpected sequence number (expected 0, got 191)
No device found.
Make sure a Ledger Nano S is connected and in the Tezos Wallet app.
Nov 18 16:41:53 - client.signer.ledger: WARNING: The device at [USB_<IDENTIFIER>] is not a Tezos application
Nov 18 16:41:53 - client.signer.ledger: APDU level error: Unexpected sequence number (expected 0, got 191)
jhartzell42 commented 5 years ago

This is because of the U2F support in the Wallet App interacting with macOS's USB support and the OCaml version of the HIDAPI. We can give you a special build without U2F support as a stopgap. We are working on a better solution.

smondet commented 5 years ago

To make detection consistent on MacOSX one needs to get the unreleased fixes from the Hidapi library.

If you got Hidapi from Homebrew, you are in luck:

 brew install hidapi --HEAD

pulls the master branch.


The full "rebuild" of tezos-client with Hidapi's master branch looks like:

brew unlink hidapi   # remove the current one
brew install autoconf autmake libtool  # Just keep installing stuff until the following command succeeds:
brew install hidapi --HEAD

Then just need to rebuild ocaml-hidapi + Tezos, so in the ./tezos repository:

opam reinstall hidapi
make all build-test
./tezos-client list connected ledgers  # should work consistently