Skip to content
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

feat: Compare bincode to CBOR, FlexBuffers and Protobuf - implement best #7513

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
f2640c0
Use ciborium for serialization of Program
aakoshh Feb 25, 2025
348e43a
fixup! Use ciborium for serialization of Program
aakoshh Feb 25, 2025
d9df721
Compared bincode against CBOR
aakoshh Feb 25, 2025
948cd8e
Use FlexBuffers for serialization
aakoshh Feb 25, 2025
67e98a9
Measure and display FlexBuffer sizes
aakoshh Feb 25, 2025
13a440f
Define protobuf schema for Program
aakoshh Feb 26, 2025
44c8afe
Refactor package names
aakoshh Feb 26, 2025
d89166f
Merge remote-tracking branch 'origin/master' into 7511-compare-progra…
aakoshh Feb 26, 2025
17654ca
Brillig opcodes
aakoshh Feb 27, 2025
ebb1369
Add ProtoReprF
aakoshh Feb 27, 2025
08d17fb
Switch to ProtoSchema
aakoshh Feb 27, 2025
33a32b6
BrilligOpcode encode
aakoshh Feb 27, 2025
f2fcc5c
Split up conversions
aakoshh Feb 27, 2025
0734118
Encoder for usize
aakoshh Feb 27, 2025
a2494c2
All brillig encoding
aakoshh Feb 27, 2025
f96c33e
Separate native. Work with IntoIterator
aakoshh Feb 27, 2025
d4e8745
Move Expression to native
aakoshh Feb 27, 2025
36701d8
Finish encoding acir
aakoshh Feb 27, 2025
70deca7
WIP
aakoshh Feb 28, 2025
a66a9e7
Switch to protobuf serialization in Program
aakoshh Feb 28, 2025
e21fccc
Bincode vs Protobuf
aakoshh Feb 28, 2025
717bdc6
Decode native types
aakoshh Feb 28, 2025
856afe3
Decoding brillig enums
aakoshh Feb 28, 2025
db5f5ed
Decoding brillig
aakoshh Feb 28, 2025
c32d67c
Decoding acir WIP
aakoshh Feb 28, 2025
28c2500
Rename _msg to _wrap
aakoshh Mar 3, 2025
ed6f56c
Decode acir
aakoshh Mar 3, 2025
246f017
Use unsafe with env::set_var
aakoshh Mar 3, 2025
7836684
Merge remote-tracking branch 'origin/master' into 7511-compare-progra…
aakoshh Mar 3, 2025
cd8952b
Format code
aakoshh Mar 3, 2025
ce4624b
Update expected serialized bytes in tests
aakoshh Mar 3, 2025
e37084b
Assert deserialization equals original
aakoshh Mar 3, 2025
070bc74
Update bytecode in TS tests
aakoshh Mar 3, 2025
8dac5f8
Encode/decode witness
aakoshh Mar 3, 2025
aae1e4d
Use protobuf in WitnessMap and WitnessStack
aakoshh Mar 3, 2025
7eb28ac
Fix TS formatting
aakoshh Mar 3, 2025
4aad815
Trying to add Arbitrary
aakoshh Mar 3, 2025
efb5910
Enable Arbitrary
aakoshh Mar 3, 2025
c3ba297
Recursive strategy for HeapValueType
aakoshh Mar 4, 2025
f901854
Proptest for serialization WIP
aakoshh Mar 4, 2025
0d40a78
Comments about the env var
aakoshh Mar 4, 2025
b01d103
Assert roundtrip
aakoshh Mar 4, 2025
d5d774d
Reenable recursive strategy
aakoshh Mar 4, 2025
30548b1
Implement all BlackBoxFuncCall
aakoshh Mar 4, 2025
eb341f7
Set serialization back to bincode. Add proptest for it.
aakoshh Mar 4, 2025
bb5541b
Revert "Update expected serialized bytes in tests"
aakoshh Mar 4, 2025
fbec87e
Revert "Update bytecode in TS tests"
aakoshh Mar 4, 2025
b3ff0c9
Fix clippy
aakoshh Mar 4, 2025
a166ae9
Remove bytecode JSON and PNG
aakoshh Mar 4, 2025
27514bb
Merge remote-tracking branch 'origin/master' into 7511-compare-progra…
aakoshh Mar 4, 2025
e8df457
Use bincode in WitnessStack and WitnessMap again
aakoshh Mar 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ members = [
"acvm-repo/bn254_blackbox_solver",
# Utility crates
"utils/iter-extended",
"utils/protobuf",
]
default-members = [
"tooling/nargo_cli",
Expand Down Expand Up @@ -94,6 +95,7 @@ noirc_abi = { path = "tooling/noirc_abi" }
noirc_artifacts = { path = "tooling/noirc_artifacts" }
noirc_artifacts_info = { path = "tooling/noirc_artifacts_info" }
noir_artifact_cli = { path = "tooling/artifact_cli" }
noir_protobuf = { path = "utils/protobuf" }

# Arkworks
ark-bn254 = { version = "^0.5.0", default-features = false, features = [
Expand Down Expand Up @@ -137,6 +139,11 @@ criterion = "0.5.0"
# https://github.com/tikv/pprof-rs/pull/172
pprof = { version = "0.14", features = ["flamegraph", "criterion"] }

# Protobuf
prost = "0.13"
prost-build = "0.13"
protoc-prebuilt = "0.3"

cfg-if = "1.0.0"
dirs = "4"
serde = { version = "1.0.136", features = ["derive"] }
Expand Down
16 changes: 16 additions & 0 deletions acvm-repo/acir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,42 @@ workspace = true
[dependencies]
acir_field.workspace = true
brillig.workspace = true
noir_protobuf.workspace = true

color-eyre.workspace = true
serde.workspace = true
thiserror.workspace = true
flate2.workspace = true
bincode.workspace = true
base64.workspace = true
prost.workspace = true
serde-big-array = "0.5.1"
strum = { workspace = true }
strum_macros = { workspace = true }

proptest = { workspace = true, optional = true }
proptest-derive = { workspace = true, optional = true }

[build-dependencies]
prost-build.workspace = true
protoc-prebuilt.workspace = true

[dev-dependencies]
serde_json = "1.0"
serde-reflection = "0.3.6"
serde-generate = "0.25.1"
fxhash.workspace = true
criterion.workspace = true
pprof.workspace = true
num-bigint.workspace = true

acir = { path = ".", features = ["arb"] } # Self to turn on `arb`.

[features]
default = []
bn254 = ["acir_field/bn254"]
bls12_381 = ["acir_field/bls12_381"]
arb = ["proptest", "proptest-derive", "brillig/arb"]

[[bench]]
name = "serialization"
Expand Down
24 changes: 24 additions & 0 deletions acvm-repo/acir/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use std::path::Path;

fn main() {
let (protoc_bin, include_dir) =
protoc_prebuilt::init("29.3").expect("failed to initialize protoc");

unsafe {
std::env::set_var("PROTOC", protoc_bin);
}

prost_build::compile_protos(
&[
// DTOs for a `Program`, which work with the types in `acir.cpp`

Check warning on line 13 in acvm-repo/acir/build.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (DTOs)
"./src/proto/program.proto",
// DTOs for the `WitnessStack`, which work with the types in `witness.cpp`

Check warning on line 15 in acvm-repo/acir/build.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (DTOs)
"./src/proto/acir/witness.proto",
// A pared down DTO for `Program`, so Barretenberg can ignore the Brillig part.
// This is only included to make sure it compiles.
"./src/proto/acir/program.proto",
],
&[Path::new("./src/proto"), include_dir.as_path()],
)
.expect("failed to compile .proto schemas");
}
4 changes: 4 additions & 0 deletions acvm-repo/acir/src/circuit/brillig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use serde::{Deserialize, Serialize};
/// Inputs for the Brillig VM. These are the initial inputs
/// that the Brillig VM will use to start.
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug, Hash)]
#[cfg_attr(feature = "arb", derive(proptest_derive::Arbitrary))]
pub enum BrilligInputs<F> {
Single(Expression<F>),
Array(Vec<Expression<F>>),
Expand All @@ -15,6 +16,7 @@ pub enum BrilligInputs<F> {
/// Outputs for the Brillig VM. Once the VM has completed
/// execution, this will be the object that is returned.
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug, Hash)]
#[cfg_attr(feature = "arb", derive(proptest_derive::Arbitrary))]
pub enum BrilligOutputs {
Simple(Witness),
Array(Vec<Witness>),
Expand All @@ -24,6 +26,7 @@ pub enum BrilligOutputs {
/// a full Brillig function to be executed by the Brillig VM.
/// This is stored separately on a program and accessed through a [BrilligPointer].
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Default, Debug, Hash)]
#[cfg_attr(feature = "arb", derive(proptest_derive::Arbitrary))]
pub struct BrilligBytecode<F> {
pub bytecode: Vec<BrilligOpcode<F>>,
}
Expand All @@ -32,6 +35,7 @@ pub struct BrilligBytecode<F> {
#[derive(
Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Hash, Copy, Default, PartialOrd, Ord,
)]
#[cfg_attr(feature = "arb", derive(proptest_derive::Arbitrary))]
#[serde(transparent)]
pub struct BrilligFunctionId(pub u32);

Expand Down
Loading
Loading