Skip to content

Commit

Permalink
feat: check version for proof requests (#862)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattstam authored May 31, 2024
1 parent 86f5789 commit ce2cf6b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
3 changes: 3 additions & 0 deletions sdk/src/network/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ sol! {
uint64 nonce;
uint64 deadline;
uint32 mode;
string version;
}

struct SubmitProof {
Expand Down Expand Up @@ -94,11 +95,13 @@ impl NetworkAuth {
nonce: u64,
deadline: u64,
mode: i32,
version: &str,
) -> Result<Vec<u8>> {
let type_struct = CreateProof {
nonce,
deadline,
mode: mode as u32,
version: version.to_string(),
};
self.sign_message(type_struct).await
}
Expand Down
9 changes: 7 additions & 2 deletions sdk/src/network/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ const DEFAULT_PROVER_NETWORK_RPC: &str = "https://rpc.succinct.xyz/";
/// The default SP1 Verifier address on all chains.
const DEFAULT_SP1_VERIFIER_ADDRESS: &str = "0xed2107448519345059eab9cddab42ddc78fbebe9";

/// The timeout for a proof request to be fulfilled.
const TIMEOUT: Duration = Duration::from_secs(60 * 60);

pub struct NetworkClient {
pub rpc: TwirpClient,
pub http: HttpClientWithMiddleware,
Expand Down Expand Up @@ -172,17 +175,18 @@ impl NetworkClient {
elf: &[u8],
stdin: &SP1Stdin,
mode: ProofMode,
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() + 1000;
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())
.sign_create_proof_message(nonce, deadline, mode.into(), version)
.await?;
let res = self
.rpc
Expand All @@ -191,6 +195,7 @@ impl NetworkClient {
nonce,
deadline,
mode: mode.into(),
version: version.to_string(),
})
.await?;

Expand Down
6 changes: 5 additions & 1 deletion sdk/src/network/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::{
use crate::{SP1CompressedProof, SP1PlonkBn254Proof, SP1Proof, SP1ProvingKey, SP1VerifyingKey};
use anyhow::{Context, Result};
use serde::de::DeserializeOwned;
use sp1_prover::install::PLONK_BN254_ARTIFACTS_COMMIT;
use sp1_prover::utils::block_on;
use sp1_prover::{SP1Prover, SP1Stdin};
use tokio::{runtime, time::sleep};
Expand Down Expand Up @@ -55,7 +56,10 @@ impl NetworkProver {
log::info!("Skipping simulation");
}

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

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

let mut is_claimed = false;
Expand Down
3 changes: 3 additions & 0 deletions sdk/src/proto/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +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.
#[prost(string, tag = "5")]
pub version: ::prost::alloc::string::String,
}
/// The response for creating a proof.
#[derive(serde::Serialize, serde::Deserialize)]
Expand Down

0 comments on commit ce2cf6b

Please sign in to comment.