From 793dda4903a1ab22fb56b837985a5bd76f794229 Mon Sep 17 00:00:00 2001 From: Matt Stam Date: Thu, 11 Apr 2024 13:14:35 -0700 Subject: [PATCH] fix: use bincode for sdk serialization (#506) --- Cargo.lock | 23 --------------------- examples/fibonacci-io/script/Cargo.lock | 27 ++----------------------- sdk/Cargo.toml | 1 - sdk/src/client.rs | 16 +++++---------- 4 files changed, 7 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b332833d7d..f156990a3a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3829,28 +3829,6 @@ dependencies = [ "rustc-hex", ] -[[package]] -name = "rmp" -version = "0.8.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f9860a6cc38ed1da53456442089b4dfa35e7cedaa326df63017af88385e6b20" -dependencies = [ - "byteorder", - "num-traits", - "paste", -] - -[[package]] -name = "rmp-serde" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bffea85eea980d8a74453e5d02a8d93028f3c34725de143085a844ebe953258a" -dependencies = [ - "byteorder", - "rmp", - "serde", -] - [[package]] name = "rrs-lib" version = "0.1.0" @@ -4590,7 +4568,6 @@ dependencies = [ "prost-types", "reqwest 0.11.27", "reqwest-middleware", - "rmp-serde", "serde", "serde_json", "sp1-core", diff --git a/examples/fibonacci-io/script/Cargo.lock b/examples/fibonacci-io/script/Cargo.lock index 7a33608719..d7c24f21c8 100644 --- a/examples/fibonacci-io/script/Cargo.lock +++ b/examples/fibonacci-io/script/Cargo.lock @@ -3334,28 +3334,6 @@ dependencies = [ "rustc-hex", ] -[[package]] -name = "rmp" -version = "0.8.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f9860a6cc38ed1da53456442089b4dfa35e7cedaa326df63017af88385e6b20" -dependencies = [ - "byteorder", - "num-traits", - "paste", -] - -[[package]] -name = "rmp-serde" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bffea85eea980d8a74453e5d02a8d93028f3c34725de143085a844ebe953258a" -dependencies = [ - "byteorder", - "rmp", - "serde", -] - [[package]] name = "rrs-lib" version = "0.1.0" @@ -3901,7 +3879,6 @@ dependencies = [ "prost-types", "reqwest 0.11.27", "reqwest-middleware", - "rmp-serde", "serde", "serde_json", "sp1-core", @@ -4114,9 +4091,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.35" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef89ece63debf11bc32d1ed8d078ac870cbeb44da02afb02a9ff135ae7ca0582" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index 5c05862412..9b260049cc 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -18,7 +18,6 @@ anyhow = "1.0.80" sp1-core = { path = "../core" } futures = "0.3.30" bincode = "1.3.3" -rmp-serde = "1.1.2" tokio = { version = "1.36.0", features = ["full"] } p3-matrix = { workspace = true } p3-commit = { workspace = true } diff --git a/sdk/src/client.rs b/sdk/src/client.rs index 958e06e479..9563021bb0 100644 --- a/sdk/src/client.rs +++ b/sdk/src/client.rs @@ -5,8 +5,7 @@ use anyhow::{Ok, Result}; use futures::future::join_all; use reqwest::{Client as HttpClient, Url}; use reqwest_middleware::ClientWithMiddleware as HttpClientWithMiddleware; -use rmp_serde::{Deserializer, Serializer}; -use serde::{Deserialize, Serialize}; +use serde::{de::DeserializeOwned, Serialize}; use sp1_core::stark::StarkGenericConfig; use std::time::{SystemTime, UNIX_EPOCH}; use twirp::Client as TwirpClient; @@ -92,10 +91,8 @@ impl NetworkClient { }) .await?; - let mut program_bytes = Vec::new(); - elf.serialize(&mut Serializer::new(&mut program_bytes))?; - let mut stdin_bytes = Vec::new(); - stdin.serialize(&mut Serializer::new(&mut stdin_bytes))?; + let program_bytes = bincode::serialize(elf)?; + let stdin_bytes = bincode::serialize(&stdin)?; let program_promise = self.upload_file(&res.program_put_url, program_bytes); let stdin_promise = self.upload_file(&res.stdin_put_url, stdin_bytes); let v = vec![program_promise, stdin_promise]; @@ -115,9 +112,7 @@ impl NetworkClient { Ok(res.proof_id) } - pub async fn get_proof_status< - SC: for<'de> Deserialize<'de> + Serialize + StarkGenericConfig, - >( + pub async fn get_proof_status( &self, proof_id: &str, ) -> Result<(GetProofStatusResponse, Option>)> { @@ -136,8 +131,7 @@ impl NetworkClient { .await? .bytes() .await?; - let mut de = Deserializer::new(&proof[..]); - Some(Deserialize::deserialize(&mut de).expect("Failed to deserialize proof")) + Some(bincode::deserialize(&proof).expect("Failed to deserialize proof")) } else { None };