optimism icon indicating copy to clipboard operation
optimism copied to clipboard

simultaneously case insensitive file test.sol/Test.sol result in build contracts-bedrock fail on mac(intel)

Open samzkback opened this issue 3 years ago • 3 comments

reproduce

I am try to build from source code(master), follow the instructions provide in https://github.com/ethereum-optimism/optimism/blob/develop/CONTRIBUTING.md

when it comes to

  1. cd ops
  2. docker-compose build

it failed to build deployer, log as below:

error logs

Building deployer [+] Building 185.6s (32/34)
=> [internal] load build definition from Dockerfile.packages 0.0s => => transferring dockerfile: 46B 0.0s => [internal] load .dockerignore 0.0s ...... => [base 25/26] COPY ./integration-tests ./integration-tests 0.8s => ERROR [base 26/26] RUN yarn build 153.8s

...... #32 153.4 lerna ERR! yarn run build exited 1 in '@eth-optimism/contracts-bedrock' #32 153.4 lerna ERR! yarn run build stdout: #32 153.4 $ yarn ts-node scripts/verifyFoundryInstall.ts #32 153.4 $ /opt/optimism/node_modules/.bin/ts-node scripts/verifyFoundryInstall.ts #32 153.4 $ hardhat compile && yarn autogen:artifacts && yarn build:ts && yarn typechain ...... #32 153.4 lerna ERR! yarn run build stderr: #32 153.4 Solidity 0.8.10 is not fully supported yet. You can still use Hardhat, but some features, like stack traces, might not work correctly. #32 153.4 #32 153.4 Learn more at https://hardhat.org/reference/solidity-support #32 153.4 #32 153.4 Error HH702: Invalid artifact path /opt/optimism/packages/contracts-bedrock/forge-artifacts/test.sol/DSTest.json, its correct case-sensitive path is /opt/optimism/packages/contracts-bedrock/forge-artifacts/Test.sol/DSTest.json #32 153.4 For more info go to https://hardhat.org/HH702 or run Hardhat with --show-stack-traces #32 153.4 error Command failed with exit code 1. #32 153.4 lerna ERR! yarn run build exited 1 in '@eth-optimism/contracts-bedrock' #32 153.4 lerna WARN complete Waiting for 1 child process to exit. CTRL-C to exit immediately. #32 153.5 error Command failed with exit code 1. #32 153.5 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. #32 153.5 error Command failed with exit code 1. #32 153.5 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

root cause

Finally, I find the issue is caused by two file: File_1. packages/contracts-bedrock/node_modules/ds-test/src/test.sol File_2. packages/contracts-bedrock/node_modules/forge-std/src/Test.sol

when compiled to ABI, a directory named test.sol will be generated for File_1. Then when compile File_2, there should be a new directory Test.sol, but since mac os using a case insensitive FS, as mentioned in
https://apple.stackexchange.com/questions/334217/why-is-there-no-difference-between-2-differently-capitalized-folders, File_2's ABI will be put in test.sol, finally result in Hardhat Error HH702.

workaround / fix

Workaround by : 1. rename test.sol to ds-test.sol, 2. import "ds-test/ds-test.sol" in Test.sol and then build completely, also run as expected. Quite dirty, but I don't have more time to dig in. Please let me know if anyone have a better fix.

samzkback avatar Sep 23 '22 08:09 samzkback

Oof yeah mac specific issues... I need to start doing some development on a mac machine to surface these sort of things. cc @tynes any ideas?

smartcontracts avatar Sep 24 '22 02:09 smartcontracts

I think the bug is right around here: https://github.com/foundry-rs/hardhat/blob/726dad92b88d83d8e9858163b0ec4ac168f601d8/packages/hardhat-forge/src/forge/artifacts.ts#L323

I thought that I fixed it, see the comment that I left in the code. Would super appreciate it if you could put some log statements in that block of code and see what is going on, I don't have a mac to do development on

tynes avatar Sep 26 '22 11:09 tynes

Add some logs, seems the directory is already test.sol in your code. The issue should be happen before that.

logs

_getFullyQualifiedNameFromPath : /Users/sam/optimism/packages/contracts-bedrock/forge-artifacts/test.sol/DSTest.json +++++++++++++ _getArtifactPathSync : test.sol:DSTest +++++++++++++ _getValidArtifactPathFromFullyQualifiedNameSync : test.sol:DSTest +++++++++++++ artifactPath : /Users/sam/optimism/packages/contracts-bedrock/forge-artifacts/test.sol/DSTest.json +++++++++++++ trueCaseArtifactPath : /Users/sam/optimism/packages/contracts-bedrock/forge-artifacts/test.sol/DSTest.json _getFullyQualifiedNameFromPath : /Users/sam/optimism/packages/contracts-bedrock/forge-artifacts/test.sol/Test.json +++++++++++++ _getArtifactPathSync : test.sol:Test +++++++++++++ _getValidArtifactPathFromFullyQualifiedNameSync : test.sol:Test +++++++++++++ artifactPath : /Users/sam/optimism/packages/contracts-bedrock/forge-artifacts/test.sol/Test.json +++++++++++++ trueCaseArtifactPath : /Users/sam/optimism/packages/contracts-bedrock/forge-artifacts/test.sol/Test.json

samzkback avatar Sep 27 '22 06:09 samzkback

i have the same issue on mac intel

#26 264.9 Error HH702: Invalid artifact path /opt/optimism/packages/contracts-bedrock/forge-artifacts/test.sol/Test.json, its correct case-sensitive path is /opt/optimism/packages/contracts-bedrock/forge-artifacts/Test.sol/Test.json
#26 264.9 For more info go to https://hardhat.org/HH702 or run Hardhat with --show-stack-traces
#26 264.9 error Command failed with exit code 1.
#26 264.9 lerna ERR! yarn run build exited 1 in '@eth-optimism/contracts-bedrock'
#26 265.7 error Command failed with exit code 1.
#26 265.7 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
#26 266.5 error Command failed with exit code 1.
#26 266.5 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
------
executor failed running [/bin/sh -c yarn build]: exit code: 1
ERROR: Service 'deployer' failed to build : Build failed```

lucadonnoh avatar Mar 13 '23 14:03 lucadonnoh

Please reopen this if its still an issue, a lot has changed since this was opened. Both macos and linux devs at op labs are able to build without issues

tynes avatar Jun 16 '23 19:06 tynes