-
Notifications
You must be signed in to change notification settings - Fork 19
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
Deploying precompiles on zksync #221
Comments
Hi! Every precompile that is in main but ModExp is working correctly as precompiles, if you want to deploy them as independent contract you need to add a |
@ilitteri Recently spent a lot of time compiling and deploying contracts to zksync so would be there any convenient ways to deploy yul codes into zksync? |
There should not be any troubles, let me know if there's any though. We have an example of deploying one in testnet in #203 |
@ilitteri The static calls and outputs would work exactly as the precompiled ones right? |
Yep, again, let me know if they don't. One thing it take into account (I don't think this would be your case though), if you use our era-test-node, be aware that the output is modified in our favor (the gas used is at the starting of the output). |
@ilitteri Got this strange error while deploying EcPairing.yul, I have added
Using default deployment arguments
Here is the compiled artifact from zkSolc, I have modified from yours https://gist.github.com/zerotwodao/d24de3d22ca1c779def4a3c01fdf9f52 |
@ilitteri Seems like a compiled bytecode size for EcPairing.yul is too big. Finds out the compiled bytecode for EcPairing exceeds 200kb and the known limit for bytecode size limit is 24kb, would it be impossible to deploy? |
Hm, that's bad news. I'm not sure if it'd be possible. Are you trying to deploy on testnet or in a local-net? |
Something that could work (don't know the amount of work it'd involve) is to modularize the precompile (e.g. finite field arithmetics could be part of another library, also the curve arithmetics could be part of another library). |
@ilitteri Tried to deploy on testnet, and it seems like it is impossible unless we lift off the https://eips.ethereum.org/EIPS/eip-170 size limit, or like you said we could try modularizing the precompile. |
Do you think it would be possible to request zksync team for the deployment of those precompiles on the different addresses for the testing purpose on mainnet and testnet? It would make our contract work eventually |
Have you tried to compile it with different compilation flags? |
@ilitteri Which flags are available? |
If you run -O, --optimization <optimization> Set the optimization parameter -O[0 | 1 | 2 | 3 | s | z]. Use `3` for best performance and `z` for minimal size In your case I'd use |
@ilitteri Sorry for late reply I have successfully compiled and deployed the precompiles with ~40kb using the flag |
And seems like it is gas costy than the one available from ethereum mainnet would the gas cost for calling function can be decreased if they are deployed as a precompile? |
Amazing! Good luck then with your library.
I have no answer for this. The zkSync team is reviewing if it'd be better to have them as circuits instead of as Yul contracts. For the moment, using them as contracts in testnet. |
Closing the issue as it seems to be solved as said here. |
Could you please share deployment address in zkSync main or testnet |
@chervyachok Sure EcAdd: '0xbF3F280F177Befe658A6973E0E57c38d62d1bCc8' EcMul: '0x8277B56C128e62356306C5a702E1fC2c3dB7192F' EcPairing: '0x49a31d9776B80450d7E5D514D9a753C99D800E9d' |
@zerotwodao
However same code (with address 8) works as expected in normal evm, and out[0] is 1 Did you managed to make it work ? |
@chervyachok Have you tested with the ethereum testnets for your code? With my case with the gist posted above it works as intended |
Hello,
We are currently making a use of zkSNARK Pairing library and would like to use the precompiles prior of deployment to zksync.
https://gist.github.com/chriseth/f9be9d9391efc5beb9704255a8e2989d
@ilitteri Would it be possible to deploy them now?
Thanks.
The text was updated successfully, but these errors were encountered: