Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dx: migrate to foundry/forge #11

Open
5 tasks
sripwoud opened this issue Jun 25, 2024 · 8 comments
Open
5 tasks

dx: migrate to foundry/forge #11

sripwoud opened this issue Jun 25, 2024 · 8 comments
Assignees
Labels
dx 🔧 Developer experience question ❔ Further information is requested tests 🧪 Adding missing or correcting existing tests

Comments

@sripwoud
Copy link
Member

sripwoud commented Jun 25, 2024

https://book.getfoundry.sh/forge/

Not urgent. And more a question: would contracts authors support this change?
Aiming for a faster local dx and ci.

Significant change. Especially all the tests will have to be rewritten. (forge tests are written in solidity, not in ts/js)

EDIT:
I suggest migrating to forge pkg after pkg to facilitate reviews and possibly work distribution (a single PR to cover everything would likely be huge)

@sripwoud sripwoud self-assigned this Jun 25, 2024
@sripwoud sripwoud added tests 🧪 Adding missing or correcting existing tests dx 🔧 Developer experience labels Jun 25, 2024
@sripwoud sripwoud added this to ZK-Kit Jun 25, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in ZK-Kit Jun 25, 2024
@cedoor cedoor moved this from 📋 Backlog to 🗒 Tasks in ZK-Kit Jun 25, 2024
@sripwoud sripwoud added the question ❔ Further information is requested label Jun 25, 2024
@sripwoud sripwoud moved this from 🗒 Tasks to 📋 Backlog in ZK-Kit Jun 25, 2024
@sripwoud sripwoud moved this from 📋 Backlog to 🗒 Tasks in ZK-Kit Jun 25, 2024
@0xjei
Copy link
Member

0xjei commented Jun 28, 2024

https://book.getfoundry.sh/forge/

Not urgent. And more a question: would contracts authors support this change? Aiming for a faster local dx and ci.

Significant change. Especially all the tests will have to be rewritten. (forge tests are written in solidity, not in ts/js)

yes, I'd love to see this change for excubiae package.

@cedoor
Copy link
Member

cedoor commented Jul 2, 2024

I think we can move on 👍🏽 It will take some time but it's not urgent as you said.

@sripwoud
Copy link
Member Author

sripwoud commented Jul 3, 2024

@0xjei in case you want to take #26
(I started the first forge PR: #23 )

@sripwoud
Copy link
Member Author

sripwoud commented Jul 4, 2024

after attempting a first refactor in #23, I have some questions and identified some challenges:
Do we want to support both forge and npm as a distribution mechanism for the contracts?

I'd say, we should aim at meeting the needs of most devs: hardhat and forge sol devs.

Regarding forge, the problem is that the way install works is repo based (org/repo), we need a foundry.toml at the top level of the repo. I don't think it is compatible with the way we currently split the contracts in sub npm packages.
To support both forge install and yarn install to distribute the contracts we need to either:

  1. "flatten" this monorepo: eg take a look at https://github.com/OpenZeppelin/openzeppelin-contracts as an example
    in this case we would only have one package: e.g @zk-kit/solidity that includes all the contracts.
    We would be able to do:
  • forge install privacy-scaling-explorations/zk-kit.solidity
  • and yarn add @zk-kit/solidity
  1. split all the packages in separate repos
    we would be able to do:
  • forge install privacy-scaling-explorations/zk-kit.solidity.lean-imt
  • and yarn add @zk-kit/lean-imt.sol

I am for 1. as it is more straightforward.
@cedoor @0xjei

@cedoor
Copy link
Member

cedoor commented Jul 4, 2024

I don't like either of them 😄

  1. How can we manage the versioning of individual libraries? Also difficult to manage audits if everything is inside a single package. IMO it goes against the idea of modularization that ZK-Kit promotes.
  2. Very hard to maintain all those repos. A lot of duplicate configurations and dispersion. Also, very confusing for devs, who need to create a new repo in the PSE org if they just want to add a new package.

I agree we should support both of them tho 🤔 I wonder if there are any other solutions, maybe using submodules?

@sripwoud
Copy link
Member Author

sripwoud commented Jul 4, 2024

  1. How can we manage the versioning of individual libraries?
    I guess we can't, we would loose that capability if we have one single big lib

  2. We could use a github template to reduce the effort to create these repos, but there will be a big risk that each deviate from each other in terms of conf yes

  3. There is the hardhat-foundry plugin. Didn't mention it earlier because that's the option I don't like so much 😆: I tried it, couldn't make it work immediately, so i gave up, concluding it was bad dx. I am not sure it can even work for a monorepo, the reason is that when using a node_modules dep with forge, you have to define a remapping for it. And with yarn, node_modules is 2 levels up in our monorepo. The remapping won't be valid when the sol package is installed (or is forge remappings smart enought to fix it?).
    ex:
    lean-imt will include a remappings.txt in its package with a content like
    poseidon-solidity\=../../node_modules/poseidon-solidity/contracts
    this relative path will be wrong after an yarn add @zk-kit/lean-imt.sol in another project

    Solution to this could be
    - stop using yarn workspaces
    - use another package manager/build system that does not hoist deps (pnpm or lerna support a no-hoist option)

@0xjei
Copy link
Member

0xjei commented Jul 4, 2024

maybe this can help to take inspiration? https://github.com/PaulRBerg/foundry-template @sripwoud @cedoor

@cedoor
Copy link
Member

cedoor commented Jul 9, 2024

@sripwoud We're already using pnpm in the snark-artifacts repo. If that solves the problem here I think we can switch to it, and maybe consider switching to pnpm in the other repos as well.

I would make sure we cannot solve the problem with Yarn first tho.

sripwoud added a commit that referenced this issue Jul 10, 2024
Publish pkg to npm and to a branch for use by `forge install`

re #11, #30
@sripwoud sripwoud moved this from 🗒 Tasks to 👀 In Review in ZK-Kit Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dx 🔧 Developer experience question ❔ Further information is requested tests 🧪 Adding missing or correcting existing tests
Projects
Status: 👀 In Review
Development

No branches or pull requests

3 participants