Feat/disk cache (#354)
- Bump rust version to `nightly-2025-07-02` because some of the nightly features we were using have been stabilized. - Introduce feature `disk_cache` which enables caching to disk. Each time an artifact is retrieved from the cache it will be read and deserialized. On a cache miss the artifact will be created, serialized and stored to disk. - Introduce feature `mem_cache` which enables caching to memory. All cached artifacts are kept in memory after they are created. The mem cache implementation avoids cloning of artifacts by extending their lifetime to `'static`. This is `unsafe` code, but I argue that this usage is safe. - Add a `build.rs` - When the feature `disk_cache` is enabled, the `build.rs` will inject env variables to the process with the git commit information, which is used to index the cached artifacts - Replace all previous cached artifacts from `LazyStatic` methods that call the cache API - Derive `Serialize, Deserialize` for all `*Target` types so that they can be serialized for caching to disk - Add finer level of caching: now we cache the `CircuitData` and `VerifierData` independently. The reason for this is that `CircuitData` is a very big artifact which is not needed for verification. So by only accessing `VerifierData` in verification we don't pay a big overhead for reading from disk and deserializing - Add missing artifacts to the cache: like the `CircuitData` for the `MainPod` indexed by `Params` - Add helper types to serialize and deserialize `CircuitData`, `CommonData` and `VerifierData` with the set of gates and generators used in the recursive MainPod circuit - Tweak the ids of our custom gates so that they remain unique when their generic parameters change - Bugfix: several tests were using the standard `vd_set` but were using MainPod circuits with non-default parameters. This was working before because there was a bug: the MainPod circuit was reporting that the used verifier data was the standard one instead of picking the one corresponding to it's own Params. Summary of breaking changes: - One and only one of the features `mem_cache` or `disk_cache` need to be enabled. By default it's `mem_cache` - To enable the `disk_cache` you need to disable the default features like this: `--no-default-features --features=backend_plonky2,zk,disk_cache` - Removed `DEFAULT_PARAMS`, instead use `Params::default()` - Removed `STANDARD_REC_MAIN_POD_CIRCUIT_DATA`, instead use `cache_get_standard_rec_main_pod_common_circuit_data` - The library is now using `nightly-2025-07-02`. Some rust language features are unstable in previous versions.
This commit is contained in:
parent
745d654048
commit
8429cd224d
35 changed files with 831 additions and 207 deletions
15
Cargo.toml
15
Cargo.toml
|
|
@ -2,6 +2,7 @@
|
|||
name = "pod2"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
build = "build.rs"
|
||||
|
||||
[lib]
|
||||
name = "pod2"
|
||||
|
|
@ -19,7 +20,7 @@ env_logger = "0.11"
|
|||
lazy_static = "1.5.0"
|
||||
thiserror = { version = "2.0.12" }
|
||||
# enabled by features:
|
||||
plonky2 = { git = "https://github.com/0xPolygonZero/plonky2", optional = true }
|
||||
plonky2 = { git = "https://github.com/0xPARC/plonky2.git", rev = "3defd60532c8693cf5e9d2e6a8412c77ca58760f", optional = true }
|
||||
serde = "1.0.219"
|
||||
serde_json = "1.0.140"
|
||||
base64 = "0.22.1"
|
||||
|
|
@ -32,6 +33,11 @@ rand = "0.8.5"
|
|||
hashbrown = { version = "0.14.3", default-features = false, features = ["serde"] }
|
||||
pest = "2.8.0"
|
||||
pest_derive = "2.8.0"
|
||||
directories = { version = "6.0.0", optional = true }
|
||||
minicbor-serde = { version = "0.5.0", features = ["std"], optional = true }
|
||||
serde_bytes = "0.11"
|
||||
serde_arrays = "0.2.0"
|
||||
sha2 = { version = "0.10.9" }
|
||||
|
||||
# Uncomment for debugging with https://github.com/ed255/plonky2/ at branch `feat/debug`. The repo directory needs to be checked out next to the pod2 repo directory.
|
||||
# [patch."https://github.com/0xPolygonZero/plonky2"]
|
||||
|
|
@ -42,10 +48,15 @@ pretty_assertions = "1.4.1"
|
|||
# Used only for testing JSON Schema generation and validation.
|
||||
jsonschema = "0.30.0"
|
||||
|
||||
[build-dependencies]
|
||||
vergen-gitcl = { version = "1.0.0", features = ["build"] }
|
||||
|
||||
[features]
|
||||
default = ["backend_plonky2", "zk"]
|
||||
default = ["backend_plonky2", "zk", "mem_cache"]
|
||||
backend_plonky2 = ["plonky2"]
|
||||
zk = []
|
||||
metrics = []
|
||||
time = []
|
||||
examples = []
|
||||
disk_cache = ["directories", "minicbor-serde"]
|
||||
mem_cache = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue