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

Feature/trezor reconnect #1874

Open
wants to merge 2 commits into
base: refactor/wallet-generic-signer
Choose a base branch
from

Conversation

OBorce
Copy link
Contributor

@OBorce OBorce commented Jan 30, 2025

If the trezor device returns an USB IO error it might mean that the trezor device has been disconnected, in that case try to reconnect to the device and try the failed operation again.

@OBorce OBorce force-pushed the feature/trezor-recconect branch 2 times, most recently from 4f6708d to e0f00b5 Compare January 31, 2025 07:32
@OBorce OBorce force-pushed the refactor/wallet-generic-signer branch from 69592f8 to f16c3e3 Compare February 3, 2025 10:47
Copy link
Member

@azarovh azarovh left a comment

Choose a reason for hiding this comment

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

Needs a rebase

@OBorce OBorce force-pushed the feature/trezor-recconect branch 2 times, most recently from 8a33777 to f8578ef Compare February 3, 2025 16:46
Err(trezor_client::Error::TransportSendMessage(
trezor_client::transport::error::Error::Usb(rusb::Error::Io),
)) => {
let (mut new_client, data) = find_trezor_device()?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Calling find_trezor_device on each operation is not a great idea. What if another device is returned?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we check the public keys again, and if it is a different device we error out.

Copy link
Contributor

Choose a reason for hiding this comment

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

we check the public keys again, and if it is a different device we error out.

I understand this, the point was that it looks conceptually wrong.

Currently, the question is why do we need it if you already call init_device every time. Can't it recover the session after a usb error?

And even if it can't, calling find_trezor_device still seems wrong. Perhaps then you should split find_trezor_device into 2 functions - the "find" part and the "connect" part, so that the former is still called only once.

Comment on lines +159 to +174
Err(trezor_client::Error::TransportSendMessage(
trezor_client::transport::error::Error::Usb(rusb::Error::Io),
)) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO instead of calling the operation and then checking for error we should just unconditionally call Trezor::initialize, passing to it the previosly obtained session_id (it's inside features). At least this is recommended in the docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added an init_device(session_id) call which internally calls initialize before each operation.

@OBorce OBorce force-pushed the refactor/wallet-generic-signer branch 2 times, most recently from 82b71a8 to c9c1c91 Compare February 25, 2025 07:54
@OBorce OBorce closed this Feb 25, 2025
@OBorce OBorce force-pushed the feature/trezor-recconect branch from f8578ef to c9c1c91 Compare February 25, 2025 11:20
@OBorce OBorce reopened this Feb 25, 2025
@OBorce OBorce force-pushed the feature/trezor-recconect branch 2 times, most recently from 2df0787 to cf6ce8c Compare February 26, 2025 12:35
@OBorce OBorce force-pushed the refactor/wallet-generic-signer branch from 48716c3 to 67609d5 Compare February 28, 2025 08:15
@OBorce OBorce force-pushed the feature/trezor-recconect branch from cf6ce8c to 66a4f17 Compare February 28, 2025 08:55
@OBorce OBorce force-pushed the refactor/wallet-generic-signer branch from 67609d5 to 220ace1 Compare February 28, 2025 09:58
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

Successfully merging this pull request may close these issues.

3 participants