foundry-rs / foundry-rs/foundry

feat(`config`): add chain dependent `solc` config and support in multichain scripts

Open
#9,840 16 comments 0 reactions 2 assignees Claimed by @grandizzy View on GitHub
A-config Cmd-forge-script T-feature
Dominant language
Rust
Stars
10.6k
Forks
2.6k
Avg merge
16h 38m
Merged PRs (30d)
511

Description

### Component

Forge

### Describe the feature you would like

At bgd we rely quite a lot on multichain scripts, which worked fine as long as Aave was only deployed on shanghai compatible blockchains.
With the recent expansion to linea(london) and zksync(zksolc) we're reaching a point where our workarounds no longer work.

Deploying for different chains, we try to solve with `profiles`.
```
[profile.bnb]
evm_version = 'shanghai'

[profile.linea]
evm_version = 'london'
```

One issue we face here is that whenever switching the evm version a complete recompile is needed. It would be great if the cache was per evm_version, so things only have to be recompiled once.

---

While the above issue is annoying, one more problematic thing is that multichain scripts (single script switching between networks) will always run with a single solc & evm_version. This leads to problematic situations:
- if you select `london` (with the goal to unite on the lowest accross chains), the script might fail with `not activated` when touching sth deployed on shanghai or cancun
- if you select `cancun` you will end up deploying non executable code on chains that are stuck on london
- another caveat is that when you rely on address prediction based on create2, addresses might be different then expected

Currently I don't see any solution for this problem, the workaround we currently use is to no longer use multichain scripts... which ofc is painful.
It would be great if one could configure solc per chainId and dynamically switch based on which network is currently forked. No idea how this could work, but I guess if using forge multichain this would be a must.

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.