0xPolygonZero / zk_evm

Apache License 2.0
68 stars 20 forks source link

Make getting circuit version more stable #311

Open BGluth opened 1 week ago

BGluth commented 1 week ago

When we determine the version of serialized circuits that we should use for a given version of zero_bin, we use the version of evm_arithmetization that is set in Cargo.lock. This is perfect as a way to version serialized circuits, but the way we do this at runtime is not the best for distributing a binary for others to use.

Currently this is the process:

While the above should work fine in development settings, this is probably going to be an issue once we start building and redistributing the zero_bin binary since it's going to attempt to look for Cargo.lock in the location that it was built in.

Ideally instead, if we can read the version set in Cargo.lock at compile time and bake the version string into the binary, this is probably the most optimal solution. However, doing this requires using a proc macro which (at the moment) requires a sub-crate that only contains proc macros and nothing else.

While we could create a sub-crate just for this, I also noticed that no crate exists for reading a project's Cargo.lock at compile time, which I find a bit surprising. When I have a bit of free time, I'm going to attempt to create a public crate to do this, since I think there are probably a lot of other projects that could also use this.

BGluth commented 6 days ago

Update: I'm going to take the time to write a generic library to query Cargo.lock at compile time. Might not be ready for a while, so the proper fix might take a bit.