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

forge script --ledger deployment fails #2709

Closed
2 tasks done
dekz opened this issue Aug 11, 2022 · 9 comments · Fixed by #2790
Closed
2 tasks done

forge script --ledger deployment fails #2709

dekz opened this issue Aug 11, 2022 · 9 comments · Fixed by #2790
Labels
C-forge Command: forge Cmd-forge-script Command: forge script T-bug Type: bug
Milestone

Comments

@dekz
Copy link

dekz commented Aug 11, 2022

Component

Forge

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

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (6cd6618 2022-08-11T00:05:44.416299Z)

What command(s) is the bug in?

forge script --ledger

Operating System

macOS (Apple Silicon)

Describe the bug

I can successfully use cast send --ledger but am unable to use forge script --ledger with error of:

Error:
hidapi error: hid_error is not implemented yet

Can confirm that cast send works exactly as expected, so could be my misuse of forge script.

I'm using the following command

forge script script/abcd/Deploy.s.sol -f $ETH_RPC_URL -vvvv --ledger --hd-paths "m/44'/60'/0'/1" --legacy --broadcast --sender "0xABCD"

I can confirm that 0xABCD is at the hd-path m/44'/60'/0'/1

Immediately switching over to cast send and there is no issue at all.

cast send 0xABCD --hd-path "m/44'/60'/0'/1" --ledger --value 0 --legacy

Successfully sends a transaction to itself from itself using the ledger

@dekz dekz added the T-bug Type: bug label Aug 11, 2022
@gakonst gakonst added this to Foundry Aug 11, 2022
@gakonst gakonst moved this to Todo in Foundry Aug 11, 2022
@gakonst
Copy link
Member

gakonst commented Aug 11, 2022

@joshieDo i think we've seen this before? Was it because maybe smart contract interactions are not set to TRUE in the Ledger?

@dekz dekz changed the title forge script: deployment with ledger fails forge script: deployment with ledger fails Aug 11, 2022
@dekz dekz changed the title forge script: deployment with ledger fails forge script --ledger deployment fails Aug 11, 2022
@onbjerg onbjerg added C-forge Command: forge Cmd-forge-script Command: forge script labels Aug 11, 2022
@onbjerg onbjerg added this to the v1.0.0 milestone Aug 11, 2022
@joshieDo
Copy link
Collaborator

Was it because maybe smart contract interactions are not set to TRUE in the Ledger?

I didn't even know that being a thing. @dekz Can you confirm?

Sometimes this error occurs when another process takes ownership of the device and doesn't let go. But given Immediately switching over to cast send and there is no issue at all., it's probably not related.

@dekz
Copy link
Author

dekz commented Aug 12, 2022

Was it because maybe smart contract interactions are not set to TRUE in the Ledger?

Not sure what this option is, are you refering to blind signing? In which case this is enabled, and cast send --ledger is able to perform the transaction I wanted forge script --ledger to execute (by manually sending the arguments from forge script into cast send).

My script is essentially a contract CREATE then an interaction. I've whittled this down to just a CREATE and still see this error with forge script --ledger.

I'll try simpler and simpler scripts to see if anything is successful.

@joshieDo
Copy link
Collaborator

I don't have a ledger with me at the moment, in a few days I can try it out as well. What version is your ledger on?

@dekz
Copy link
Author

dekz commented Aug 13, 2022

Ledger Firmware / Secure Element: 2.1.0
Microcontroller: 1.12
Bootloader: 0.11

Ethereum App: 1.9.18
Blind singing: Enabled

@dekz
Copy link
Author

dekz commented Aug 13, 2022

Just trying a basic test, deploying a simple contract.

MyContract.sol

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.6.5;

contract MyContract {
    function getBlockNumber()
        public
        view
        returns (uint256)
    {
        return block.number;
    }
}

Deploy.s.sol

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.6.5;

import "forge-std/Script.sol";
import "forge-std/Test.sol";

import "./MyContract.sol";

contract DScript is Script, Test {
    function run() public {
        emit log_named_address("msg.sender", msg.sender);
        vm.startBroadcast();
        MyContract myContract = new MyContract();
        vm.stopBroadcast();

        emit log_named_uint("blockNumber", myContract.getBlockNumber());
    }
}
λ forge script script/Deploy.s.sol -f $ETH_RPC_URL -vvvv --ledger --hd-paths "m/44'/60'/0'/2" --legacy --broadcast --verify --sender "0xABCD"

[⠰] Compiling...
[⠃] Compiling 2 files with 0.6.12
[⠒] Solc 0.6.12 finished in 410.01ms
Compiler run successful
Traces:
  [97165] DScript::run()
    ├─ emit log_named_address(key: "msg.sender", val: 0xABCD)
    ├─ [0] VM::startBroadcast()
    │   └─ ← ()
    ├─ [25475] → new MyContract@"0x6765…52ea"
    │   └─ ← 127 bytes of code
    ├─ [0] VM::stopBroadcast()
    │   └─ ← ()
    ├─ [175] MyContract::getBlockNumber() [staticcall]
    │   └─ ← 31827097
    ├─ emit log_named_uint(key: "blockNumber", val: 31827097)
    └─ ← ()


Script ran successfully.

== Logs ==
  msg.sender: 0xABCD
  blockNumber: 31827097
==========================
Simulated On-chain Traces:

  [80879] → new MyContract@"0x6765…52ea"
    └─ ← 127 bytes of code


==========================

Estimated total gas used for script: 105142

Estimated amount required: 0.003154260001892556 ETH

==========================

###
Finding wallets for all the necessary addresses...

Transactions saved to: /Users/jacob/projects/foundry-repro/broadcast/Deploy.s.sol/137/run-latest.json

Error:
hidapi error: hid_error is not implemented yet

@joshieDo
Copy link
Collaborator

finally got a hold of my ledger and was able to reproduce it. sorry it took so long, issue linked

Repository owner moved this from Todo to Done in Foundry Aug 15, 2022
@dekz
Copy link
Author

dekz commented Aug 15, 2022

Thanks legends, I'll try it shortly and get back to you if there are any other issues.

@dekz
Copy link
Author

dekz commented Aug 16, 2022

Confirmed working and I was able to use both forge script --ledger --hd-paths and cast send --ledger --hd-path successfully.

thanks again @joshieDo .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge Cmd-forge-script Command: forge script T-bug Type: bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants