Skip to content

Commit

Permalink
fix: use bincode for sdk serialization (#506)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattstam authored Apr 11, 2024
1 parent 80c5b63 commit 793dda4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 60 deletions.
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.

27 changes: 2 additions & 25 deletions examples/fibonacci-io/script/Cargo.lock

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

1 change: 0 additions & 1 deletion sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
16 changes: 5 additions & 11 deletions sdk/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand All @@ -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<SC: StarkGenericConfig + Serialize + DeserializeOwned>(
&self,
proof_id: &str,
) -> Result<(GetProofStatusResponse, Option<SP1ProofWithIO<SC>>)> {
Expand All @@ -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
};
Expand Down

0 comments on commit 793dda4

Please sign in to comment.