foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Forge Script --broadcast -t fails

Open wanderer opened this issue 1 year ago • 7 comments

Component

Forge

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

  • [x] Foundry
  • [ ] Foundryup

What version of Foundry are you on?

forge 0.2.0 (f625d0f 2024-04-02T00:15:52.692780824Z)

What command(s) is the bug in?

forge script --verifier sourcify ./script/deploy.s.sol:Deploy --rpc-url https://eth.llamarpc.com --broadcast --no-auto-detect -t

Operating System

Linux

Describe the bug

When I try to run a script using my trezor as a wallet i get the following.

Error:                                                                                                                                                                                       
Failed to send transaction                                                                                                                                                                   
                                                                                                                                                                                             
Context:                                                                                                                                                                                     
- (code: -32603, message: failed to send tx, data: None)      

wanderer avatar Apr 14 '24 20:04 wanderer

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

wanderer avatar Apr 14 '24 20:04 wanderer

@wanderer could you please try updating foundry to latest nightly and running script again? we've recently migrated to new wallet adapters and this migration helped to fix some Ledger issues so Trezor connections might be fixed as well

klkvr avatar Apr 14 '24 21:04 klkvr

@klkvr i update to forge 0.2.0 (89f0fb9 2024-04-14T00:20:50.727844499Z) and it "sees" the trezor now. But it doesn't use it. It still want to use PRIVATE_KEY.

in my script I have

uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");   

Should this be replaced with a something that is trezor specific?

wanderer avatar Apr 15 '24 07:04 wanderer

yeah, you should use vm.startBroadcast() or vm.startBroadcast(address) cheatcodes for hw wallets

klkvr avatar Apr 15 '24 08:04 klkvr

using vm.startBroadcast(address) works, in that the trezor is signing. Broadcasting still fails though with the following error

returned an error response: error code -32000: txIndex 0 error: nonce too high: address 0xcb7c5CA542FE243bD1622d2951dEf45c8e3Aaf3F, tx: 18 state: 

I have no idea what is address 0xcb7c5CA542FE243bD1622d2951dEf45c8e3Aaf3F. The address the i was deploying from does have nonce of 18.

I am using --trezor --hd-paths="m/44'/60'/0'/0/2" Also I have tried with various RPCs

wanderer avatar Apr 15 '24 08:04 wanderer

does 0xcb7c5CA542FE243bD1622d2951dEf45c8e3Aaf3F match any other addresses on your Trezor?

klkvr avatar Apr 15 '24 08:04 klkvr

i check the first dozen or so paths and it does not

wanderer avatar Apr 15 '24 08:04 wanderer

Issue maybe related to trezor-client package trezor/trezor-firmware#3952.

TuDo1403 avatar Jun 15 '24 08:06 TuDo1403

Pending Alloy release 0.1.5: https://github.com/alloy-rs/alloy/pull/1045

zerosnacks avatar Jul 15 '24 12:07 zerosnacks

Marking as resolved by https://github.com/alloy-rs/alloy/releases/tag/v0.2.0 and Foundry having been bumped to 0.2.0 in https://github.com/foundry-rs/foundry/pull/8305/files#diff-2e9d962a08321605940b5a657135052fbcef87b5e360662bb527c96d9a615542

Please re-open if this is still an issue

zerosnacks avatar Jul 22 '24 14:07 zerosnacks