dapphub / dapptools

Dapp, Seth, Hevm, and more

Home Page:https://dapp.tools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SRC, LIBRARIES, and TEST_LINK_LIBRARIES setup issue

namrapatel opened this issue · comments

Hello, I've been trying to sort out an issue I'm having with how the libraries are being linked when I run dapp build for a week or so now to no avail (including some probing in the dapphub.chat room). Hoping someone can see something I'm not, here!

I've got a super large pre-existing repo that I'm trying to get Dapptools to work with, there are various settings I've tried, I'll write them below and also show what the result of the respective settings are.

Setup (1):

Folder Structure:

  • eth
    • contracts
      • libraries
        • .sol library files
      • test
        • DungeonFacet.t.sol
      • DungeonFacet.sol
    • .dapprc

Note that the "src" folder is called "contracts" in this repo, I adjust DAPP_SRC in the dapprc to account for this.

.dapprc:

# Make dependencies available
export DAPP_REMAPPINGS=$(cat remappings.txt)

export DAPP_SOLC_VERSION=0.7.6
export DAPP_LINK_TEST_LIBRARIES=0
export DAPP_TEST_VERBOSITY=1
export DAPP_TEST_SMTTIMEOUT=500000
export DAPP_LIBRARIES=' contracts/libraries/LibAppStorage.sol:LibAppStorage:0x0DdeDfFe2789df61F5f76479464F568334414389 contracts/libraries/LibChecks.sol:LibChecks:0x5Fe5dAc04fe3527Cf7bDba8798F5A8b5edDfE4Af contracts/libraries/LibCreatures.sol:LibCreatures:0x1F39490BdD8e57Ed3CA877783E563cC0B329431b contracts/libraries/LibDiamond.sol:LibDiamond:0x8F8D423242782C1201c913e6F8daD057851DC1d3 contracts/libraries/LibDungeon.sol:LibDungeon:0xb52C7AbDa4EbcEc5acE01C7e15F7Dc04067CF0A3 contracts/libraries/LibImpersonation.sol:LibImpersonation:0xbE9ABd32a080f5253C6f916E9C2b4E1BD5ca4AAc contracts/libraries/LibMath.sol:LibMath:0x212D3DF701c5Fcb39eea4F8B400a9d5aBE75A012 contracts/libraries/LibPairing.sol:LibPairing:0xa6d3C85C964D6248c4F7c143A53aFCD8309Afe32 contracts/libraries/LibTypes.sol:LibTypes:0xe38C0B66937724596735111E0f2229202b2eB1c4 contracts/libraries/LibUpgrade.sol:LibUpgrade:0x7496c5C5c86FB8cE60221e5BeFf3b7806CFd09a7 contracts/libraries/LibUtils.sol:LibUtils:0xcd362a41980dfF2C801DD6752cfA36A863138825 contracts/libraries/LibVerifier1.sol:LibVerifier1:0x092c60D49F03F536c7bbf48f11bB7b84D0015CA3 lib/openzeppelin-contracts/contracts/utils/math/Math.sol:Math:0x4C10a5E25Cdd922b3e8e4b3a2b3003CBA2906955 contracts/test/lib/console.sol:Console:0xfE16a273ca58de022c476f9738dB697E6a6950Ab'
export DAPP_SRC=./contracts
export DAPP_LIB=./lib

# set so that we can deploy to local node w/o hosted private keys
export ETH_RPC_ACCOUNTS=true

if [ "$DEEP_FUZZ" == "true" ]
then 
  export DAPP_TEST_FUZZ_RUNS=50000 # Fuzz for a long time if DEEP_FUZZ is set to true.
else
  export DAPP_TEST_FUZZ_RUNS=100 # Only fuzz briefly if DEEP_FUZZ is not set to true.
fi

Result:

  • Libraries don't appear to link, even though I've specified them in DAPP_LIBRARIES in .dapprc above.
  • I'll comment out the DAPP_LIBRARIES and set DAPP_LINK_TEST_LIBRARIES=1 and see if it works in the next setup

Setup (2):

Folder Structure:

  • eth
    • contracts
      • libraries
        • .sol library files
      • test
        • DungeonFacet.t.sol
      • DungeonFacet.sol
    • .dapprc

Note that the "src" folder is called "contracts" in this repo, I adjust DAPP_SRC in the dapprc to account for this.

.dapprc:

# Make dependencies available
export DAPP_REMAPPINGS=$(cat remappings.txt)

export DAPP_SOLC_VERSION=0.7.6
export DAPP_LINK_TEST_LIBRARIES=1
export DAPP_TEST_VERBOSITY=1
export DAPP_TEST_SMTTIMEOUT=500000
# export DAPP_LIBRARIES=' contracts/libraries/LibAppStorage.sol:LibAppStorage:0x0DdeDfFe2789df61F5f76479464F568334414389 contracts/libraries/LibChecks.sol:LibChecks:0x5Fe5dAc04fe3527Cf7bDba8798F5A8b5edDfE4Af contracts/libraries/LibCreatures.sol:LibCreatures:0x1F39490BdD8e57Ed3CA877783E563cC0B329431b contracts/libraries/LibDiamond.sol:LibDiamond:0x8F8D423242782C1201c913e6F8daD057851DC1d3 contracts/libraries/LibDungeon.sol:LibDungeon:0xb52C7AbDa4EbcEc5acE01C7e15F7Dc04067CF0A3 contracts/libraries/LibImpersonation.sol:LibImpersonation:0xbE9ABd32a080f5253C6f916E9C2b4E1BD5ca4AAc contracts/libraries/LibMath.sol:LibMath:0x212D3DF701c5Fcb39eea4F8B400a9d5aBE75A012 contracts/libraries/LibPairing.sol:LibPairing:0xa6d3C85C964D6248c4F7c143A53aFCD8309Afe32 contracts/libraries/LibTypes.sol:LibTypes:0xe38C0B66937724596735111E0f2229202b2eB1c4 contracts/libraries/LibUpgrade.sol:LibUpgrade:0x7496c5C5c86FB8cE60221e5BeFf3b7806CFd09a7 contracts/libraries/LibUtils.sol:LibUtils:0xcd362a41980dfF2C801DD6752cfA36A863138825 contracts/libraries/LibVerifier1.sol:LibVerifier1:0x092c60D49F03F536c7bbf48f11bB7b84D0015CA3 lib/openzeppelin-contracts/contracts/utils/math/Math.sol:Math:0x4C10a5E25Cdd922b3e8e4b3a2b3003CBA2906955 contracts/test/lib/console.sol:Console:0xfE16a273ca58de022c476f9738dB697E6a6950Ab'
export DAPP_SRC=./contracts
export DAPP_LIB=./lib

# set so that we can deploy to local node w/o hosted private keys
export ETH_RPC_ACCOUNTS=true

if [ "$DEEP_FUZZ" == "true" ]
then 
  export DAPP_TEST_FUZZ_RUNS=50000 # Fuzz for a long time if DEEP_FUZZ is set to true.
else
  export DAPP_TEST_FUZZ_RUNS=100 # Only fuzz briefly if DEEP_FUZZ is not set to true.
fi

Result:

  • The tests pass, but I have to wait 45 seconds to let the libraries pre-deploy, which is annoying.
  • Maybe the error is with the fact that my src folder is named contracts? I'll test that in Setup 3 to see if that helps.

Setup (3):

Folder Structure:

  • eth
    • src
      • libraries
        • .sol library files
      • test
        • DungeonFacet.t.sol
      • DungeonFacet.sol
    • .dapprc

.dapprc:

# Make dependencies available
export DAPP_REMAPPINGS=$(cat remappings.txt)

export DAPP_SOLC_VERSION=0.7.6
export DAPP_LINK_TEST_LIBRARIES=1
export DAPP_TEST_VERBOSITY=1
export DAPP_TEST_SMTTIMEOUT=500000
export DAPP_LIBRARIES=' src/libraries/LibAppStorage.sol:LibAppStorage:0x0DdeDfFe2789df61F5f76479464F568334414389 src/libraries/LibChecks.sol:LibChecks:0x5Fe5dAc04fe3527Cf7bDba8798F5A8b5edDfE4Af src/libraries/LibCreatures.sol:LibCreatures:0x1F39490BdD8e57Ed3CA877783E563cC0B329431b src/libraries/LibDiamond.sol:LibDiamond:0x8F8D423242782C1201c913e6F8daD057851DC1d3 src/libraries/LibDungeon.sol:LibDungeon:0xb52C7AbDa4EbcEc5acE01C7e15F7Dc04067CF0A3 src/libraries/LibImpersonation.sol:LibImpersonation:0xbE9ABd32a080f5253C6f916E9C2b4E1BD5ca4AAc src/libraries/LibMath.sol:LibMath:0x212D3DF701c5Fcb39eea4F8B400a9d5aBE75A012 src/libraries/LibPairing.sol:LibPairing:0xa6d3C85C964D6248c4F7c143A53aFCD8309Afe32 src/libraries/LibTypes.sol:LibTypes:0xe38C0B66937724596735111E0f2229202b2eB1c4 src/libraries/LibUpgrade.sol:LibUpgrade:0x7496c5C5c86FB8cE60221e5BeFf3b7806CFd09a7 src/libraries/LibUtils.sol:LibUtils:0xcd362a41980dfF2C801DD6752cfA36A863138825 src/libraries/LibVerifier1.sol:LibVerifier1:0x092c60D49F03F536c7bbf48f11bB7b84D0015CA3 lib/openzeppelin-contracts/contracts/utils/math/Math.sol:Math:0x4C10a5E25Cdd922b3e8e4b3a2b3003CBA2906955 src/test/lib/console.sol:Console:0xfE16a273ca58de022c476f9738dB697E6a6950Ab'

# set so that we can deploy to local node w/o hosted private keys
export ETH_RPC_ACCOUNTS=true
if [ "$DEEP_FUZZ" == "true" ]
then
export DAPP_TEST_FUZZ_RUNS=50000 # Fuzz for a long time if DEEP_FUZZ is set to true.
else
export DAPP_TEST_FUZZ_RUNS=100 # Only fuzz briefly if DEEP_FUZZ is not set to true.
fi

Result :

  • This result works, but I have to wait 45 seconds for the libraries to predeploy:
  • So I'm going to set export DAPP_LINK_TEST_LIBRARIES=0 in the next setup

Setup (4)

Folder Structure:

  • eth
    • src
      • libraries
        • .sol library files
      • test
        • DungeonFacet.t.sol
      • DungeonFacet.sol
    • .dapprc

.dapprc:

# Make dependencies available
export DAPP_REMAPPINGS=$(cat remappings.txt)

export DAPP_SOLC_VERSION=0.7.6
export DAPP_LINK_TEST_LIBRARIES=0
export DAPP_TEST_VERBOSITY=1
export DAPP_TEST_SMTTIMEOUT=500000
export DAPP_LIBRARIES=' src/libraries/LibAppStorage.sol:LibAppStorage:0x0DdeDfFe2789df61F5f76479464F568334414389 src/libraries/LibChecks.sol:LibChecks:0x5Fe5dAc04fe3527Cf7bDba8798F5A8b5edDfE4Af src/libraries/LibCreatures.sol:LibCreatures:0x1F39490BdD8e57Ed3CA877783E563cC0B329431b src/libraries/LibDiamond.sol:LibDiamond:0x8F8D423242782C1201c913e6F8daD057851DC1d3 src/libraries/LibDungeon.sol:LibDungeon:0xb52C7AbDa4EbcEc5acE01C7e15F7Dc04067CF0A3 src/libraries/LibImpersonation.sol:LibImpersonation:0xbE9ABd32a080f5253C6f916E9C2b4E1BD5ca4AAc src/libraries/LibMath.sol:LibMath:0x212D3DF701c5Fcb39eea4F8B400a9d5aBE75A012 src/libraries/LibPairing.sol:LibPairing:0xa6d3C85C964D6248c4F7c143A53aFCD8309Afe32 src/libraries/LibTypes.sol:LibTypes:0xe38C0B66937724596735111E0f2229202b2eB1c4 src/libraries/LibUpgrade.sol:LibUpgrade:0x7496c5C5c86FB8cE60221e5BeFf3b7806CFd09a7 src/libraries/LibUtils.sol:LibUtils:0xcd362a41980dfF2C801DD6752cfA36A863138825 src/libraries/LibVerifier1.sol:LibVerifier1:0x092c60D49F03F536c7bbf48f11bB7b84D0015CA3 lib/openzeppelin-contracts/contracts/utils/math/Math.sol:Math:0x4C10a5E25Cdd922b3e8e4b3a2b3003CBA2906955 src/test/lib/console.sol:Console:0xfE16a273ca58de022c476f9738dB697E6a6950Ab'

# set so that we can deploy to local node w/o hosted private keys
export ETH_RPC_ACCOUNTS=true
if [ "$DEEP_FUZZ" == "true" ]
then
export DAPP_TEST_FUZZ_RUNS=50000 # Fuzz for a long time if DEEP_FUZZ is set to true.
else
export DAPP_TEST_FUZZ_RUNS=100 # Only fuzz briefly if DEEP_FUZZ is not set to true.
fi

Result:

  • Somehow, a test that was passing in (3) is now failing, when the only change was export DAPP_LINK_TEST_LIBRARIES=0
  • Confused what is going on here

Conclusion

I can't seem to find a setup of DAPP_LIBRARIES, DAPP_SRC, and DAPP_LINK_TEST_LIBRARIES that does the following things:

  1. Allows me to use the folder name contracts as my src folder and;
  2. Doesn't make me wait 45 seconds to predeploy libraries every time I run dapp build
commented

Library linking is unfortunately currently very slow. If you need linked libraries then I think you will just have to wait.