ZkSync Compilation error #5066
-
❗
|
| System | Model |
|---|---|
| ERC-4337 | Application-layer AA (EntryPoint-based) |
| zkSync Era | Protocol-native AA (Bootloader-based) |
These systems are fundamentally different and cannot share the same dependency graph under --zksync.
⚠️ Why forge build Works
forge builduses standard solc targeting EVM.
EVM supports EXTCODECOPY.
But this does not verify compatibility with zkSync Era.
✅ Correct Workaround (Clean Solution)
The proper fix is to separate projects entirely.(But will be too much of a hustle at the moment)
Recommended Structure
root/
│
├── erc4337/
│ ├── foundry.toml
│ ├── src/
│ ├── script/
│ └── lib/
│
└── zk-native/
├── foundry.toml
├── src/
├── script/
└── lib/
Then compile independently:
cd erc4337
forge build
cd zk-native
forge build --zksyncThis ensures:
- ERC-4337 compiles under EVM
- zk-native compiles under EraVM
- No incompatible libraries get compiled together
🏁 Conclusion
There is no compiler flag workaround for this issue.
The only correct architectural solution is:
🔥 Separate ERC-4337 and zk-native AA into distinct Foundry projects.
Attempting to compile ERC-4337 EntryPoint under zkSync’s EraVM will always fail due to unsupported opcodes.
If anyone has found a cleaner dependency-isolation strategy within a single monorepo, I’d be interested in hearing about it.
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
@PatrickAlphaC, your insight will be appreciated, sir. |
Beta Was this translation helpful? Give feedback.
-
|
@EngrPips @PatrickAlphaC It turns out the issue had nothing to do with my folder structure or Foundry config. I was using a newer version of After downgrading to the older commit If you want to stay on the newer version of |
Beta Was this translation helpful? Give feedback.
@EngrPips @PatrickAlphaC It turns out the issue had nothing to do with my folder structure or Foundry config. I was using a newer version of
account-abstractionmainy inEntryPoint.solthat includes recent updates likeEIP-7702support and someinternal refactoring. Those changes caused the compiler to generate low-level instructions that zkSync’szksolcdoesn’t currently handle properly, which is why I kept hitting theEXTCODECOPYerror.After downgrading to the older commit
7af70c8, the same one used in the Cyfrin repo, everything compiled without any issues. So in my case, it was simply a version compatibility mismatch betweenaccount-abstractionandzksolc.If you want to stay on th…