foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.31k stars 1.75k forks source link

`No associated wallet for addresses` when using trezor with `forge script` #9294

Open shaspitz opened 2 days ago

shaspitz commented 2 days ago

Component

Forge

Have you ensured that all of these are up to date?

What version of Foundry are you on?

forge 0.2.0 (e028b92 2024-11-11T00:26:04.968342000Z)

What command(s) is the bug in?

forge script

Operating System

macOS (Apple Silicon)

Describe the bug

Maybe related to https://github.com/foundry-rs/foundry/issues/7342.

I am experiencing an issue with forge 0.2.0 (e028b92 2024-11-11T00:26:04.968342000Z). I'm trying to specify forge script to use the m/44'/60'/0'/0/0 derivation path from my trezor, but the command is not finding/using the correct derivation path.

Note I am using trezor safe 5 (one of the newer models).

Command:

forge script scripts/validator-registry/DeployVanillaRegistry.s.sol:Deploy --rpc-url $URL --sender $SENDER --via-ir --chain-id $CHAIN_ID --use 0.8.26 --broadcast --verify --trezor --hd-paths 'm/44'\''/60'\''/0'\''/0/0'

Then password is asked for twice on hw wallet

Error:

Error: No associated wallet for addresses: [*SENDER from above*]. Unlocked wallets: [0xfb20adf75beb049fa5b60c798c3045e548c4cdfb]

This unlocked wallet is unrecognized, and does not show up in Trezor Suite.

shaspitz commented 2 days ago

Note also in Trezor Suite, SENDER from the commands says its derivation path is m/44'/60'/0'/0/0

shaspitz commented 2 days ago

Current trezor firmware version is https://github.com/trezor/trezor-firmware/blob/7f373ae71eca855dd41b4a0fdcc7cadaa13a8281/core/CHANGELOG.T3T1.md

shaspitz commented 2 days ago

@klkvr @zerosnacks am I missing some configuration here, or is this a bug? Thanks!

grandizzy commented 2 days ago

@shaspitz try passing HD path as --hd-paths "m/44'/60'/0'/0/0" see a sample here https://github.com/foundry-rs/foundry/issues/4692#issuecomment-2390714190

shaspitz commented 2 days ago

Hey, I just tried

forge script scripts/validator-registry/DeployVanillaRegistry.s.sol:Deploy --rpc-url $URL --sender $SENDER --via-ir --chain-id $CHAIN_ID --use 0.8.26 --broadcast --verify --trezor --hd-paths "m/44'/60'/0'/0/0"

and had the same resp:

Error: No associated wallet for addresses: [*SENDER from above*]. Unlocked wallets: [0xfb20adf75beb049fa5b60c798c3045e548c4cdfb]
grandizzy commented 2 days ago

thanks, then most probably same with #7342 you linked

shaspitz commented 2 days ago

To add context, if I replace --hd-paths with --mnemonic-indexes and try values of 0,1,2, etc., I can get the unlocked address to change. But that address is never the same as the expected sender

zerosnacks commented 22 hours ago

considering we inherit most of the underlying logic through Alloy https://github.com/alloy-rs/alloy/tree/main/crates/signer-trezor and then the trezor-client next steps would be to narrow down if this is an issue in Foundry or in the underlying