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: specify version in network client #1481

Merged
merged 4 commits into from
Sep 5, 2024
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
20 changes: 12 additions & 8 deletions crates/sdk/src/network/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,16 @@ impl NetworkClient {
Ok((res, proof))
}

/// Get all the proof requests for a given status.
/// Get all the proof requests for a given status. Also filter by circuit version if provided.
pub async fn get_proof_requests(
&self,
status: ProofStatus,
circuit_version: Option<&str>,
) -> Result<GetProofRequestsResponse> {
self.with_error_handling(
self.rpc.get_proof_requests(GetProofRequestsRequest { status: status.into() }),
)
self.with_error_handling(self.rpc.get_proof_requests(GetProofRequestsRequest {
status: status.into(),
circuit_version: circuit_version.map(|v| v.to_owned()),
}))
.await
}

Expand All @@ -131,23 +133,25 @@ impl NetworkClient {
elf: &[u8],
stdin: &SP1Stdin,
mode: ProofMode,
version: &str,
circuit_version: &str,
) -> Result<String> {
let start = SystemTime::now();
let since_the_epoch = start.duration_since(UNIX_EPOCH).expect("Invalid start time");
let deadline = since_the_epoch.as_secs() + TIMEOUT.as_secs();

let nonce = self.get_nonce().await?;
let create_proof_signature =
self.auth.sign_create_proof_message(nonce, deadline, mode.into(), version).await?;
let create_proof_signature = self
.auth
.sign_create_proof_message(nonce, deadline, mode.into(), circuit_version)
.await?;

let res = self
.with_error_handling(self.rpc.create_proof(CreateProofRequest {
signature: create_proof_signature.to_vec(),
nonce,
deadline,
mode: mode.into(),
version: version.to_string(),
circuit_version: circuit_version.to_string(),
}))
.await?;

Expand Down
3 changes: 1 addition & 2 deletions crates/sdk/src/network/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ impl NetworkProver {
log::info!("Skipping simulation");
}

let version = SP1_CIRCUIT_VERSION;
let proof_id = client.create_proof(elf, &stdin, mode, version).await?;
let proof_id = client.create_proof(elf, &stdin, mode, SP1_CIRCUIT_VERSION).await?;
log::info!("Created {}", proof_id);

if NetworkClient::rpc_url() == DEFAULT_PROVER_NETWORK_RPC {
Expand Down
13 changes: 10 additions & 3 deletions crates/sdk/src/proto/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ pub struct CreateProofRequest {
/// The deadline for the proof request, signifying the latest time a fulfillment would be valid.
#[prost(uint64, tag = "4")]
pub deadline: u64,
/// The client version used, in the form of an 8-character git commit hash.
/// The SP1 circuit version to use for the proof.
#[prost(string, tag = "5")]
pub version: ::prost::alloc::string::String,
pub circuit_version: ::prost::alloc::string::String,
}
/// The response for creating a proof.
#[derive(serde::Serialize, serde::Deserialize)]
Expand Down Expand Up @@ -229,9 +229,12 @@ pub struct GetProofStatusResponse {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetProofRequestsRequest {
/// The status of the proof requests to get.
/// The status of the proof requests to filter for.
#[prost(enumeration = "ProofStatus", tag = "1")]
pub status: i32,
/// The SP1 circuit version of the proof requests to filter for.
#[prost(string, optional, tag = "2")]
pub circuit_version: ::core::option::Option<::prost::alloc::string::String>,
}
/// A proof request.
#[derive(serde::Serialize, serde::Deserialize)]
Expand All @@ -247,6 +250,9 @@ pub struct RequestedProof {
/// Proof requester's address.
#[prost(bytes = "vec", tag = "3")]
pub requester: ::prost::alloc::vec::Vec<u8>,
/// The SP1 circuit version to use for the proof.
#[prost(string, tag = "4")]
pub circuit_version: ::prost::alloc::string::String,
}
/// The response for getting proof requests by a given status.
#[derive(serde::Serialize, serde::Deserialize)]
Expand Down Expand Up @@ -493,6 +499,7 @@ impl UnclaimReason {
}
}
}
pub use twirp;
pub const SERVICE_FQN: &str = "/network.NetworkService";
#[twirp::async_trait::async_trait]
pub trait NetworkService {
Expand Down
Loading