Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recurrent errors when signing with Ledger (MacOS) #396

Open
andreibancioiu opened this issue Jan 11, 2024 · 3 comments
Open

Recurrent errors when signing with Ledger (MacOS) #396

andreibancioiu opened this issue Jan 11, 2024 · 3 comments

Comments

@andreibancioiu
Copy link
Contributor

andreibancioiu commented Jan 11, 2024

/home/user/multiversx-sdk/mxpy-venv/lib/python3.11/site-packages/ledgercomm/interfaces/hid_device.py", line 137, in recv
    data_chunk: bytes = bytes(self.device.read(64 + 1))
                              ^^^^^^^^^^^^^^^^^^^^^^^^
  File "hid.pyx", line 234, in hid.device.read
OSError: read error

Signing works upon a few retries.

@mihaieremia
Copy link

I also got this error right after I signed on the device

  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/truststaking/multiversx-sdk/mxpy-venv/lib/python3.11/site-packages/multiversx_sdk_cli/cli.py", line 122, in <module>
    ret = main(sys.argv[1:])
          ^^^^^^^^^^^^^^^^^^
  File "/Users/truststaking/multiversx-sdk/mxpy-venv/lib/python3.11/site-packages/multiversx_sdk_cli/cli.py", line 29, in main
    _do_main(cli_args)
  File "/Users/truststaking/multiversx-sdk/mxpy-venv/lib/python3.11/site-packages/multiversx_sdk_cli/cli.py", line 56, in _do_main
    args.func(args)
  File "/Users/truststaking/multiversx-sdk/mxpy-venv/lib/python3.11/site-packages/multiversx_sdk_cli/cli_contracts.py", line 377, in upgrade
    tx = contract.prepare_upgrade_transaction(sender, args)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/truststaking/multiversx-sdk/mxpy-venv/lib/python3.11/site-packages/multiversx_sdk_cli/contracts.py", line 148, in prepare_upgrade_transaction
    tx.signature = bytes.fromhex(owner.sign_transaction(tx))
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/truststaking/multiversx-sdk/mxpy-venv/lib/python3.11/site-packages/multiversx_sdk_cli/accounts.py", line 103, in sign_transaction
    signature = do_sign_transaction_with_ledger(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/truststaking/multiversx-sdk/mxpy-venv/lib/python3.11/site-packages/multiversx_sdk_cli/ledger/ledger_functions.py", line 21, in do_sign_transaction_with_ledger
    signature = ledger_handler.sign_transaction(tx_payload, sign_using_hash)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/truststaking/multiversx-sdk/mxpy-venv/lib/python3.11/site-packages/multiversx_sdk_cli/ledger/ledger_app_handler.py", line 79, in sign_transaction
    return self._do_sign(tx_bytes, ins_signing_method)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/truststaking/multiversx-sdk/mxpy-venv/lib/python3.11/site-packages/multiversx_sdk_cli/ledger/ledger_app_handler.py", line 115, in _do_sign
    return self.get_signature_from_apdus(apdus)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/truststaking/multiversx-sdk/mxpy-venv/lib/python3.11/site-packages/multiversx_sdk_cli/ledger/ledger_app_handler.py", line 127, in get_signature_from_apdus
    sw, response = self.transport.recv()
                   ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/truststaking/multiversx-sdk/mxpy-venv/lib/python3.11/site-packages/ledgercomm/transport.py", line 188, in recv
    return self.com.recv()
           ^^^^^^^^^^^^^^^
  File "/Users/truststaking/multiversx-sdk/mxpy-venv/lib/python3.11/site-packages/ledgercomm/interfaces/hid_device.py", line 142, in recv
    assert data_chunk[3:5] == seq_idx.to_bytes(2, byteorder="big")```

@andreibancioiu
Copy link
Contributor Author

@mihaieremia, thank you for the provided details 🙏

PyPi package does not yet contain v1.2.1 (a patch related to newer versions of MacOS), as of January 2024.

Temporary workaround:

. "/home/andrei/multiversx-sdk/mxpy-venv/bin/activate"
pip3 install git+https://github.com/LedgerHQ/[email protected]

Then, do a quick check:

mxpy --verbose ledger version

The output should include something like:

DEBUG    ledgercomm: hid.enumerate(), devices: [...] 

This means that ledgercomm[hid] v1.2.1 is installed correctly.

Related to:

@andreibancioiu
Copy link
Contributor Author

Reinstalling mxpy (which reinstalls ledgercomm[hid]) should fix the issue 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants