Skip to content

Conversation

felipemadero
Copy link
Contributor

@felipemadero felipemadero commented Sep 25, 2025

Depends on #4347

Why this should be merged

  • Ledger operations against the moved ledger-avalanche-go module still fail sporadically with hidapi: unknown failure and APDU 0x6987 errors.
  • Introducing a bounded retry with backoff around device calls restores stability when the hardware wallet needs a moment to respond.

How this works

  • Adds retryOnHIDAPIError, which retries selected ledger calls up to five times with a linear backoff.
  • Wraps app discovery, key derivation, signing, version reads, and disconnect in the new retry helper

How this was tested

  • A example program made to test all p/x/c txs, signed with ledger, on local network + (somes on fuji) was made to check the stability of the ledger interaction and to check the availability of sign vs sign hash on new ledger app. Nano S+. Macos.
    After the fix, the program executes many times with no issues.

Need to be documented in RELEASES.md?

felipemadero and others added 8 commits September 25, 2025 16:31
Update invalid state sync test case to use an object {} instead of
number 1234 to properly test the "failed to cast to bool" error path.
Changes the test case from using numeric value 1234 to an empty object {}
to properly trigger the "failed to cast to bool" error in the test chain.
This fixes the TestStateSyncEnabledFromEnvVars/invalid_state_sync_value test.
@felipemadero felipemadero marked this pull request as ready for review October 1, 2025 18:04
Base automatically changed from update-ledger-library-v1.1.0-new to master October 1, 2025 18:07
@Copilot Copilot AI review requested due to automatic review settings October 2, 2025 15:26
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds retry logic to handle intermittent failures when communicating with Ledger hardware wallets, specifically addressing "hidapi: unknown failure" and APDU 0x6987 errors that occur sporadically with the ledger-avalanche-go module.

  • Implements a bounded retry mechanism with linear backoff for Ledger device operations
  • Wraps critical Ledger calls (app discovery, key derivation, signing, version reads, disconnect) with retry logic
  • Uses up to 5 retry attempts with 200ms incremental delays to improve hardware wallet stability

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

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

Successfully merging this pull request may close these issues.

2 participants