morpho-org / metamorpho

MetaMorpho
https://morpho.org
Other
53 stars 26 forks source link

chore: use toplevel out/ for importing Morpho bytecode #388

Closed adhusson closed 10 months ago

adhusson commented 10 months ago

Fixes the following issue : after a fresh checkout, forge test fails. The relevant trace portion is:

├─ [0] VM::getCode("lib/morpho-blue/out/Morpho.sol/Morpho.json") [staticcall]
    │   └─ ← failed to read from "~/metamorpho/lib/morpho-blue/out/Morpho.sol/Morpho.json": No such file or directory (os error 2)

The current fix is to cd lib/morpho-blue; forge build; cd ../.., and to do it again after any change to the local Morpho.sol.

This PR uses foundry's multiple compiler version support to compile Morpho separately. No more need to build inside the lib/morpho-blue dir to get the Morpho bytecode.

Important: Morpho's solidity version will be used, but metamorpho's optimization settings will be used.

adhusson commented 10 months ago

Updated hardhat config by adding a compiler. Hardhat will select the highest compiler version compatible with the pragma in each instance.

FYI you could also be more specific and do the following:

overrides: {
      "src/mocks/MorphoImport.sol": {
          version: "0.8.19",
          settings: ...
      }
}