Deployer says Stack Too Deep
Closed this issue · 5 comments
Deployment.s.sol with certain complexity insists it is reached to "Stack too deep".
forge <subcommand> --via-ir
evades that error but compilation is gonna be way too slow.
I guess JIT EVM can compress deployment code into LLVM and no stack problem would be shown tho. Let's discuss here.
I find the idea of JIT EVM really fascinating. However, it seems that currently, there's no support for JIT execution of generic contract code, so it might be best to wait for native support in Foundry. In the meantime, keeping method chains short can be a workaround to avoid the Stack Too Deep
compile error. This approach might result in some repetitive code, but using:
mc.init("hogehoge");
mc.use(FunctionA);
mc.use(FunctionB);
mc.deploy();
instead of chaining them together like:
mc.init("hogehoge").use(FunctionA).use(FunctionB).deploy();
can be effective.
It sounds good for a bundle, although, could you suggest some ideas on multi-bundle deployment script usecase.
The mc
is preserving internal state and cache-related problems might undermine stability of deployment process.
I guess mc.reset();
alike cache cleaner is good for now. Or we can reset state inside mc.deploy();
logic.
I agree that implementing mc.reset()
and incorporating a reset within mc.deploy()
makes a lot of sense. I'll go ahead and implement those changes.
Okay, close this issue when you merged that feature.
I've implemented mc.reset()
. I also experimented with incorporating a reset within mc.deploy()
, but decided against it for now since it would make toProxyAddress()
, which is likely used in many use cases, unavailable after deployment. It's possible to preserve just the proxy context, so if needed, please feel free to reopen this issue.