Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce build time when running foundry migrations (#11003)
* chore(protocol/migrations_sol): adds time tracking To measure how long it takes to run the entire script from start to finish. * chore(protocol/migrations_sol): cuts migration time by 35% Worked as expected, but stopped working because of what I think is a cache issue. Latest best time to run script (with improvement): 338 sec or 5.6 min Improvement margin: -34% or 2.9 min Committing this WIP to do a clean checkout and see if it's a cache issue. * chore(protocol/contracts): adds `@celo-contracts/` import This uses remappings instead of relative import `./` * fix(protocol): updates `@celo-contracts` remapping * refactor(protocol/migrations_sol): adds `deploy_libraries.sh` script Currently running `create_and_migrate_anvil_devchain.sh` successfully builds the libraries (fast) as expected. It then fails with: ```sh Deploying libraries... Deploying library: AddressSortedLinkedListWithMedian Error: Found incompatible Solidity versions: test-sol/governance/validators/IntegerSortedLinkedListMock-8.sol (>=0.8.0 <0.8.20) imports: contracts-0.8/common/linkedlists/IntegerSortedLinkedList.sol (>=0.8.0 <0.8.20) lib/openzeppelin-contracts8/contracts/utils/math/SafeMath.sol (^0.8.0) contracts/common/linkedlists/SortedLinkedList.sol (^0.5.13) lib/openzeppelin-contracts/contracts/math/SafeMath.sol (^0.5.0) contracts/common/linkedlists/LinkedList.sol (^0.5.13) lib/openzeppelin-contracts/contracts/math/SafeMath.sol (^0.5.0) ``` * fix(protocol/contracts-0.8): updates `@celo-contracts-8` Previously I mistakenly updated to `@celo-contracts` which is on the wrong solidity version. * fix(protocol/migrations_sol): changes directory to deploy contracts Previously the script tried to deploy contracts in the `protocol/` but the build output in the temp directory. * fix(protocol/contracts): undo `@celo-` imports Using `@celo-contracts` and `@celo-contracts-8` syntax with remappings broke the truffle build process. Truffle only allows imports (with or without remapping) that are resolved within `node_modules`. That means I don't think I can't use a directory that is not in `node_modules` (with or without remapping). > Truffle supports dependencies installed via NPM. To import contracts from a dependency, use the following syntax > `import "somepackage/SomeContract.sol";` > Here, `somepackage` represents a package installed via NPM, and `SomeContract.sol` represents a Solidity source file provided by that package. Source: https://archive.trufflesuite.com/docs/truffle/how-to/compile-contracts/#importing-dependencies-via-file-name > Since the path didn't start with `./`, Truffle knows to look in your project's `node_modules` directory for the `example-truffle-library` folder. From there, it resolves the path to provide you the contract you requested. Source: https://archive.trufflesuite.com/docs/truffle/how-to/package-management-via-npm/#within-your-contracts I decided to revert the changes to the import and the need for remappings, and instead try to make the library compilation work with relative paths. At this point 1. the truffle compilation works with ```sh # within protocol directory yarn build:sol ``` 2. the Foundry migrations work ```sh # within protocol directory ./migrations_sol/create_and_migrate_anvil_devchain.sh ``` * chore(protocol/migrations_sol): moves `mkdir` command up The script was breaking on CI: ```sh mkdir: cannot create directory ‘/home/runner/work/celo-monorepo/celo-monorepo/packages/protocol/.tmp/libraries’: No such file or directory ``` Source: https://github.com/celo-org/celo-monorepo/actions/runs/9223759766/job/25377654339?pr=11003#step:18:78 That's expected since the temp directory is only created after the "deploy libraries" script is called. * chore(protocol/migrations_sol): removes `TODO` comment * chore(protocol/migrations_sol): removes unused library commands I tested this, and these extra commands are not used or needed. Also removes `TODO` comment.
- Loading branch information