`forge create` and `forge script` not working with --ledger
Component
Forge
Have you ensured that all of these are up to date?
- [X] Foundry
- [X] Foundryup
What version of Foundry are you on?
forge 0.2.0 (d4e6b43 2023-12-04T13:39:22.221218000Z)
What command(s) is the bug in?
forge create && forge script
Operating System
macOS (Apple Silicon)
Describe the bug
forge create --ledger and forge script --ledger --broadcast does not prompt for tx signature on the ledger. The cli outputs that it's sending the transaction but nothing actually pops up on my ledger. Changing back to version forge 0.2.0 (60ec002 2023-12-04T13:54:02.349674000Z) does not cause this issue and the transactions shows up on my ledger. cast send --ledger also works great on the latest build.
I just ran into the same issue after doing foundryup.
After hours of trying various things to make this work, I found this issue here and installed the exact version that @mpeyfuss is mentioning, where ledger integration is supposed to work.
I can confirm that it works with that version but not with the latest on in 0.2.0
/cc'ing @Evalir has we've been discussing this issue offline.
Same issue here—reverting to the suggested commit here worked for me.
Same issue
Any updates on this issue? cc @gakonst
an update on my end, I was able to run foundryup to get the latest version. Deploying with my ledger worked on some new repos but not the one I was originally having issues with. Not sure if that helps or hurts.
This is quite annoying though as I need to deploy and verify contracts on arbitrum-sepolia and I can't verify with the older build and can't deploy from a ledger with the newer build.
Also facing this, on latest nightly on a script with 3 txns, foundry asked me to sign the first and then it just stopped.
I'd appreciate a minimal repro for this.
You should be able to try to deploy with a ledger to sepolia with the default Counter contract. Haven't tried this specifically but basically any forge create command with the --ledger flag is not working for me.
- run
forge init hello_foundry - run
cd hello_foundry - run `forge create src/Counter.sol:Counter --ledger --rpc-url <ENTER_SEPOLIA_RPC_URL_HERE>
- You should see that there is no transaction popping up on the ledger but the cli output shows that it is sending the tx (waiting for signature).
thanks, I'll give this a try with my ledger
I am also facing this problem. Tried with updating to latest foundry version (foundryup), using the recommended commit in @mpeyfuss comments, but without success.
Any news on if this will be solved?
For me downgrading to: foundryup --commit 60ec00296f00754bc21ed68fd05ab6b54b50e024 works, but that#s obviously a bit sad as it's quite old.
Here's a reproduction of the issue: https://github.com/bgd-labs/static-a-token-v3/blob/main/scripts/Deploy.s.sol#L152
Running forge script scripts/Deploy.s.sol:DeployScroll --rpc-url scroll --broadcast --ledger --mnemonics foo --mnemonic-indexes 1 --sender <sender> --verify -vvvv --slow will result in the script being stuck without the ledger opening.
Also seeing this - trying to deploy via --ledger if the script requires multiple txns, it just asks for the first transaction then stops.
https://github.com/collectivexyz/revolution-protocol deploy script in packages/revolution you can repro easily
FOUNDRY_PROFILE=default forge script script/DeployRevolutionBuilder.s.sol:DeployContracts --rpc-url https://mainnet.base.org/ --broadcast --verify -vvvvv --etherscan-api-key [] --ledger --chain-id 8453 --with-gas-price 1000 --verifier etherscan --verifier-url https://api.basescan.org/api\? --skip test --via-ir --slow
seeing the same after 3/14 txs on Base.
@mattsse any hunch on what is going wrong?
This issue is getting increasingly problematic for us as on tooling we rely on patches from newer foundry versions, but for actual execution of things ppl have to downgrade to a version from early november last year.
Starting investigation - ty!!
I was not able to reproduce this on latest nightly for both script and create :/
@cxkoda @sakulstra @rocketman-21 @sendra @mpeyfuss could you please upgrade to latest nightly and try again? If the issue persists please drop here your setup information so we could test more.
Following info would be useful:
- Operating system
- Ledger model
- Ledger Ethereum app version (Can be found directly on Ledger in Ethereum app)
- Ledger OS Version (Didn't find it on Ledger but it is displayed in Ledger Live under "My Ledger")
@klkvr for me it still does not work.
- Operating system: macos (latest)
- Ledger model: ledger nano s
- ledger ethereum: 1.10.4 (latest)
- on latest foundry nightly
Here's the repro: https://github.com/bgd-labs/v2-stable-debt-offboarding/blob/main/scripts/Deploy.s.sol#L7 It will log:
##
Sending transactions [0 - 0].
and then remain stuck forever (nothing ever showing on my ledger)
- Operating system: macos (latest)
- Ledger model: ledger nano s
- ledger ethereum: 1.10.4 (latest)
- on latest foundry nightly
Here's the repro: https://github.com/bgd-labs/v2-stable-debt-offboarding/blob/main/scripts/Deploy.s.sol#L7 It will log:
## Sending transactions [0 - 0].and then remain stuck forever (nothing ever showing on my ledger)
Hi @sakulstra
I'm able to reproduce the stalling issue, given your repro. I'm also able to verify that on commit 60ec00296f00754bc21ed68fd05ab6b54b50e024 it does work as you reported.
I'm using the following setup:
- latest version of Foundry
- macOS (latest)
- Ledger Nano S Plus (latest)
- Both firmware versions 1.1.10 and 1.1.11 (latest), no difference
It appears that if I comment out / remove the external libraries section in foundry.toml in your linked repo the stalling issue disappears.
libraries=[
"src/contracts/protocol/libraries/logic/ReserveLogic.sol:ReserveLogic:0xe58575ba47a348e3c2f9b7ec3eccfbb189ccc6ec",
"src/contracts/protocol/libraries/logic/GenericLogic.sol:GenericLogic:0xeae736e5d6560169f9285c62492f8a89fb4ab790",
"src/contracts/protocol/libraries/logic/ValidationLogic.sol:ValidationLogic:0xb65308a8F4cE57a72F13312CeCBaAf47601A574A"
]
One thing I noticed is that when running the script a connection is opened to the Ledger, as no other connection is accepted, but it does not request a signature on the screen.
@mpeyfuss I'm unable to replicate the same stalling behavior with your example
You should be able to try to deploy with a ledger to sepolia with the default Counter contract. Haven't tried this specifically but basically any
forge createcommand with the--ledgerflag is not working for me.
- run
forge init hello_foundry- run
cd hello_foundry- run `forge create src/Counter.sol:Counter --ledger --rpc-url <ENTER_SEPOLIA_RPC_URL_HERE>
- You should see that there is no transaction popping up on the ledger but the cli output shows that it is sending the tx (waiting for signature).
~~I'm trying to put together a minimal reproduction repo here: https://github.com/zerosnacks/foundry-repro-6516~~
~~I would appreciate if you could run the repo to see if it runs correctly (the current version should) on your end and help think with me if there are any special, niche or complex aspects to your codebase (like external libraries). It is unclear to me whether the stalling issue at transaction 0/n and the failure case after a few transaction steps that some report are related.~~
hi @zerosnacks there are definitely external dependencies in the libraries I work with but they are all installed with forge install.
Experiencing this as well with the latest forge on Mac OS 14.4 using a ledger nano x.
To reproduce:
- Clone https://github.com/jbx-protocol/juice-721-delegate
yarn install && forge installforge script DeploySepolia --rpc-url "<RPC_URL_HERE>" --broadcast --ledger --mnemonic-indexes <INDEX_HERE> --sender "<SENDER_HERE>" --optimize --optimizer-runs 200 -vvv
Here's the output I get:
[⠒] Compiling...
No files changed, compilation skipped
Script ran successfully.
== Logs ==
registry 0xD75d2EeF7Fe65Bf9f46D7ef0b21EdED98cB0a3A4
project deployer 0x7495D2F6BB7D316Ab216C7e7575942DF80645D68
store 0x221Ac848c8ccE1A14d266bb489279CF078e9FFf5
## Setting up 1 EVM.
==========================
Chain 11155111
Estimated gas price: 3.002930112 gwei
Estimated total gas used for script: 20785379
Estimated amount required: 0.062417040488432448 ETH
==========================
##
Sending transactions [0 - 4].
Stays there forever. Here's the deploy script:
contract DeploySepolia is Script {
IJBDirectory jbDirectory = IJBDirectory(0x3B3Bd16cc76cd53218e00b600bFCa27aA5057794);
IJBOperatorStore jbOperatorStore = IJBOperatorStore(0x8f63C744C0280Ef4b32AF1F821c65E0fd4150ab3);
bytes4 payMetadataDelegateId = bytes4("721P");
bytes4 redeemMetadataDelegateId = bytes4("721R");
JBTiered721DelegateDeployer delegateDeployer;
JBTiered721DelegateProjectDeployer projectDeployer;
JBTiered721DelegateStore store;
function run() external {
IJBDelegatesRegistry registry = IJBDelegatesRegistry(
stdJson.readAddress(
vm.readFile(
"node_modules/@jbx-protocol/juice-delegates-registry/broadcast/Deploy.s.sol/11155111/run-latest.json"
),
".transactions[0].contractAddress"
)
);
// Make a static call for sanity check
assert(registry.deployerOf(address(0)) == address(0));
vm.startBroadcast();
JBTiered721Delegate noGovernance = new JBTiered721Delegate(jbDirectory, jbOperatorStore, payMetadataDelegateId, redeemMetadataDelegateId);
JBTiered721GovernanceDelegate onchainGovernance = new JBTiered721GovernanceDelegate(
jbDirectory,
jbOperatorStore,
payMetadataDelegateId,
redeemMetadataDelegateId
);
delegateDeployer = new JBTiered721DelegateDeployer(onchainGovernance, noGovernance, registry);
store = new JBTiered721DelegateStore();
projectDeployer = new JBTiered721DelegateProjectDeployer(
jbDirectory,
delegateDeployer,
jbOperatorStore
);
console.log("registry ", address(registry));
console.log("project deployer", address(projectDeployer));
console.log("store ", address(store));
}
}
@filipviz / @mpeyfuss / @sakulstra / @rocketman-21 / @horsefacts / @soloblack / @sendra could you please re-test against the latest Foundry nightly (to update run: foundryup)?
It appears that the bug is related to the kb size of the contract suite being deployed.
In yesterday's nightly a PR was merged to switch to Alloy's Ledger signer and, from my testing on @sakulstra's and @rocketman-21's repo's, it appears to have been resolved by that: https://github.com/foundry-rs/foundry/releases/tag/nightly-460319558e455611be1de64be8364c65c6896d15
I can confirm that I am able to get transactions to show on my ledger, however, now for every chain, the gas price selected is low by a factor of about 1000. Ex: Sepolia gas price right now is around 1 gwei but forge script shows that it is 0.001 gwei
@mpeyfuss today's nightly includes fix for eip-1559 estimation, could you please check if the issue is resolved?
@klkvr so far so good!