matter-labs / foundry-zksync

Fork of Foundry tailored for zkSync environment
Apache License 2.0
299 stars 130 forks source link

Getting an error when running ./install-foundry-zksync #479

Closed yohanelly95 closed 3 months ago

yohanelly95 commented 4 months ago

Component

Forge, Cast, Anvil

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

What version of Foundry are you on?

forge 0.2.0 (af97b2c 2024-07-18T00:22:15.301937000Z)

What command(s) is the bug in?

./install-foundry-zksync

Operating System

macOS (Apple Silicon)

Describe the bug

Getting this error when I try install foundry zksync

dyld[84514]: Library not loaded: /opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib
  Referenced from: <3500C876-31CB-3E4D-B268-A9322EAB1577> /Users/yohan/.foundry/bin/forge
  Reason: tried: '/opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib' (no such file), '/opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib' (no such file)
Installation verification failed. Forge is not properly installed.
Chipe1 commented 4 months ago

I was able to fix this by running brew install libusb. A warning to install this also shows up when I run the install command Not sure why it needs USB access though 🤔

yohanelly95 commented 4 months ago

thanks, @Chipe1, by the way were you able to run a forge script that deploys contracts/post deployment tasks using the --zksync flag?

I tried it, but the txn never goes through. I just get caught waiting for a receipt but it is never received. @bxpana the command looks something like this

forge script script/Deployer.s.sol:Deployer --rpc-url https://zksync-sepolia.drpc.org     --optimize  -vvvv --ledger --sender ${DEPLOYER_ADDRESS} --hd-paths "m/44'/60'/${index}'/0/0" --broadcast --zksync --slow

I signed the first txn, but it does not get submitted to the network (zksync sepolia) and the script gets stuck waiting for a receipt indefinitely.

Chipe1 commented 4 months ago

Hey @yohanelly95 , no sorry didn't try any deployment yet. Was only using it for running tests(using hardhat for deployments). Will let you know in case I do

rangoc commented 3 months ago

I am getting the same error, although running the command: brew install libusb didn't solve it for me, and I am still getting the same error as the OP.

nbaztec commented 3 months ago

libusb is required due to the --ledger support. It can be verified with brew list libusb if you have it installed. Unfortunately, ledger isn't supported for foundry-zksync yet. It's on the roadmap but can take a while due to the existence of other critical features.

rangoc commented 3 months ago

I am getting the same error, although running the command: brew install libusb didn't solve it for me, and I am still getting the same error as the OP.

Just replying to myself and giving an update for others that might be helpful. brew install libusb is a solution to this issue, but for me the issue was a bit more rooted. Because I am using a Mac with Arm64 architecture, and Apple Silicon chip, the default location where homebrew was installing packages such as libusb was wrong. Hence why I couldn't solve this issue just by simply doing brew install libusb. After some re-wiring and relocating of homebrew I finally got it to install packages in a correct location and then homebrew install libusb did actually solve the issue, like for the others.

Karrq commented 3 months ago

It seems like your issue has been resolved @yohanelly95, right? For now, we don't yet support --ledger option so you wouldn't be able to use your script with your ledger device. Please feel free to reopen the issue if you get other installation problems, and feel also free to open other issues if you have more!

yohanelly95 commented 3 months ago

It seems like your issue has been resolved @yohanelly95, right? For now, we don't yet support --ledger option so you wouldn't be able to use your script with your ledger device. Please feel free to reopen the issue if you get other installation problems, and feel also free to open other issues if you have more!

I see @Karrq, so for zksync mainnet I would like to deploy contracts using a hardware device. How do you suggest I do this? Note: there are multiple contracts and a post-deployment script that would need to be run as well to initialise them correctly for eg.

Karrq commented 3 months ago

Right now there's no solution for your issue @yohanelly95, directly in foundry-zksync, but it is planned.

Perhaps you could use foundry to generate the transactions you want to submit using the broadcast functionality (you'd find them in json files under the broadcast/{chain_id} folder after your script is run), and somehow then sign them using your device, before finally broadcasting them on chain (not necessarily thru cast), but tbh I couldn't find a clear and easy way to do this

fedealconada commented 2 months ago

I am getting the same error, although running the command: brew install libusb didn't solve it for me, and I am still getting the same error as the OP.

Just replying to myself and giving an update for others that might be helpful. brew install libusb is a solution to this issue, but for me the issue was a bit more rooted. Because I am using a Mac with Arm64 architecture, and Apple Silicon chip, the default location where homebrew was installing packages such as libusb was wrong. Hence why I couldn't solve this issue just by simply doing brew install libusb. After some re-wiring and relocating of homebrew I finally got it to install packages in a correct location and then homebrew install libusb did actually solve the issue, like for the others.

I was having this issue and this solution worked :) Just to expand a little bit, what I've done was basicall: 1) save the names of all existing packages on a file arch -x86_64 /usr/local/bin/brew bundle dump --global 2) re-install homebrew (which will be installed in the correct directory /opt/homebrew) /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 3) re-install all packages that were installed on the other homebrew /opt/homebrew/bin/brew bundle install --global 4) install foundry ./install-foundry-zksync 5) remove old homebrew /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)" -- --path=/usr/local

Source: https://docs.brew.sh/Common-Issues#unintentional-dual-homebrew-installations