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

chore: remove messagepack serialization logic #2865

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 0 additions & 23 deletions Cargo.lock

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

2 changes: 0 additions & 2 deletions acvm-repo/acir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ acir_field.workspace = true
brillig.workspace = true
serde.workspace = true
thiserror.workspace = true
rmp-serde = { version = "1.1.0", optional = true }
flate2 = "1.0.24"
bincode.workspace = true

Expand All @@ -30,4 +29,3 @@ strum_macros = "0.24"
default = ["bn254"]
bn254 = ["acir_field/bn254", "brillig/bn254"]
bls12_381 = ["acir_field/bls12_381", "brillig/bls12_381"]
serialize-messagepack = ["rmp-serde"]
19 changes: 0 additions & 19 deletions acvm-repo/acir/src/circuit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,24 +125,6 @@ impl Circuit {
PublicInputs(public_inputs)
}

#[cfg(feature = "serialize-messagepack")]
pub fn write<W: std::io::Write>(&self, writer: W) -> std::io::Result<()> {
let buf = rmp_serde::to_vec(&self).unwrap();
let mut deflater = flate2::write::DeflateEncoder::new(writer, Compression::best());
deflater.write_all(&buf).unwrap();

Ok(())
}
#[cfg(feature = "serialize-messagepack")]
pub fn read<R: std::io::Read>(reader: R) -> std::io::Result<Self> {
let mut deflater = flate2::read::DeflateDecoder::new(reader);
let mut buf_d = Vec::new();
deflater.read_to_end(&mut buf_d).unwrap();
let circuit = rmp_serde::from_slice(buf_d.as_slice()).unwrap();
Ok(circuit)
}

#[cfg(not(feature = "serialize-messagepack"))]
pub fn write<W: std::io::Write>(&self, writer: W) -> std::io::Result<()> {
let buf = bincode::serialize(&self).unwrap();
let mut encoder = flate2::write::GzEncoder::new(writer, Compression::default());
Expand All @@ -151,7 +133,6 @@ impl Circuit {
Ok(())
}

#[cfg(not(feature = "serialize-messagepack"))]
pub fn read<R: std::io::Read>(reader: R) -> std::io::Result<Self> {
let mut gz_decoder = flate2::read::GzDecoder::new(reader);
let mut buf_d = Vec::new();
Expand Down
43 changes: 0 additions & 43 deletions acvm-repo/acir/src/native_types/witness_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,6 @@ use thiserror::Error;

use crate::native_types::Witness;

#[cfg(feature = "serialize-messagepack")]
#[derive(Debug, Error)]
enum SerializationError {
#[error(transparent)]
MsgpackEncode(#[from] rmp_serde::encode::Error),

#[error(transparent)]
MsgpackDecode(#[from] rmp_serde::decode::Error),

#[error(transparent)]
Deflate(#[from] std::io::Error),
}

#[cfg(not(feature = "serialize-messagepack"))]
#[derive(Debug, Error)]
enum SerializationError {
#[error(transparent)]
Expand Down Expand Up @@ -92,20 +78,6 @@ impl From<BTreeMap<Witness, FieldElement>> for WitnessMap {
}
}

#[cfg(feature = "serialize-messagepack")]
impl TryFrom<WitnessMap> for Vec<u8> {
type Error = WitnessMapError;

fn try_from(val: WitnessMap) -> Result<Self, Self::Error> {
let buf = rmp_serde::to_vec(&val).map_err(|err| WitnessMapError(err.into()))?;
let mut deflater = flate2::write::DeflateEncoder::new(buf.as_slice(), Compression::best());
let mut buf_c = Vec::new();
deflater.read_to_end(&mut buf_c).map_err(|err| WitnessMapError(err.into()))?;
Ok(buf_c)
}
}

#[cfg(not(feature = "serialize-messagepack"))]
impl TryFrom<WitnessMap> for Vec<u8> {
type Error = WitnessMapError;

Expand All @@ -118,21 +90,6 @@ impl TryFrom<WitnessMap> for Vec<u8> {
}
}

#[cfg(feature = "serialize-messagepack")]
impl TryFrom<&[u8]> for WitnessMap {
type Error = WitnessMapError;

fn try_from(bytes: &[u8]) -> Result<Self, Self::Error> {
let mut deflater = flate2::bufread::DeflateDecoder::new(bytes);
let mut buf_d = Vec::new();
deflater.read_to_end(&mut buf_d).map_err(|err| WitnessMapError(err.into()))?;
let witness_map =
rmp_serde::from_slice(buf_d.as_slice()).map_err(|err| WitnessMapError(err.into()))?;
Ok(Self(witness_map))
}
}

#[cfg(not(feature = "serialize-messagepack"))]
impl TryFrom<&[u8]> for WitnessMap {
type Error = WitnessMapError;

Expand Down