Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"editor.inlineSuggest.enabled": true,
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer",
"editor.formatOnSave": true,
"editor.formatOnSave": false,
"editor.hover.enabled": true
},
"editor.rulers": [
Expand Down
21 changes: 20 additions & 1 deletion crates/sdk/src/network/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ use crate::network::proto::{
};

#[cfg(feature = "sepolia")]
use crate::network::proto::types::{GetProofRequestParamsRequest, GetProofRequestParamsResponse};
use crate::network::proto::types::{
GetProofRequestParamsRequest, GetProofRequestParamsResponse, GetProversByUptimeRequest,
};

/// A client for interacting with the network.
pub struct NetworkClient {
Expand Down Expand Up @@ -146,6 +148,23 @@ impl NetworkClient {
Ok(B256::from_slice(&vk_hash))
}

/// Get the prover whitelist.
///
/// # Details
/// Uses the key that the client was initialized with.
#[cfg(feature = "sepolia")]
pub async fn get_provers_by_uptime(&self) -> Result<Vec<Address>> {
self.with_retry(
|| async {
let mut rpc = self.prover_network_client().await?;
let res = rpc.get_provers_by_uptime(GetProversByUptimeRequest {}).await?;
Ok(res.into_inner().provers.into_iter().map(|p| Address::from_slice(&p)).collect())
},
"getting prover whitelist",
)
.await
}

/// Registers a program with the network if it is not already registered.
pub async fn register_program(&self, vk: &SP1VerifyingKey, elf: &[u8]) -> Result<B256> {
let vk_hash = Self::get_vk_hash(vk)?;
Expand Down
4,578 changes: 3,162 additions & 1,416 deletions crates/sdk/src/network/proto/sepolia/network.rs

Large diffs are not rendered by default.

1,350 changes: 789 additions & 561 deletions crates/sdk/src/network/proto/sepolia/types.rs

Large diffs are not rendered by default.

48 changes: 41 additions & 7 deletions crates/sdk/src/network/prove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ pub struct NetworkProveBuilder<'a> {
pub(crate) gas_limit: Option<u64>,
pub(crate) tee_2fa: bool,
pub(crate) min_auction_period: u64,
pub(crate) whitelist: Vec<Address>,
pub(crate) whitelist: Option<Vec<Address>>,
pub(crate) auctioneer: Option<Address>,
pub(crate) executor: Option<Address>,
pub(crate) verifier: Option<Address>,
pub(crate) max_price_per_pgu: Option<u64>,
pub(crate) max_price_per_gas: Option<u64>,
}

impl NetworkProveBuilder<'_> {
Expand Down Expand Up @@ -203,11 +203,37 @@ impl NetworkProveBuilder<'_> {
/// let builder = client.prove(&pk, &stdin).skip_simulation(true).run();
/// ```
#[must_use]
#[deprecated(note = "Use `simulate` instead")]
pub fn skip_simulation(mut self, skip_simulation: bool) -> Self {
self.skip_simulation = skip_simulation;
self
}

/// Set whether to skip the local execution simulation step.
///
/// # Details
/// This method sets whether to skip the local execution simulation step. If the simulation
/// step is skipped, the request will sent to the network without verifying that the execution
/// succeeds locally (without generating a proof). This feature is recommended for users who
/// want to optimize the latency of the proof generation on the network.
///
/// # Example
/// ```rust,no_run
/// use sp1_sdk::{Prover, ProverClient, SP1Stdin};
///
/// let elf = &[1, 2, 3];
/// let stdin = SP1Stdin::new();
///
/// let client = ProverClient::builder().network().build();
/// let (pk, vk) = client.setup(elf);
/// let builder = client.prove(&pk, &stdin).simulate(true).run();
/// ```
#[must_use]
pub fn simulate(mut self, simulate: bool) -> Self {
self.skip_simulation = !simulate;
self
}

/// Sets the fulfillment strategy for the client.
///
/// # Details
Expand Down Expand Up @@ -258,6 +284,7 @@ impl NetworkProveBuilder<'_> {
/// .unwrap();
/// ```
#[must_use]
#[cfg(not(feature = "sepolia"))]
pub fn cycle_limit(mut self, cycle_limit: u64) -> Self {
self.cycle_limit = Some(cycle_limit);
self
Expand Down Expand Up @@ -291,6 +318,7 @@ impl NetworkProveBuilder<'_> {
/// .unwrap();
/// ```
#[must_use]
#[cfg(feature = "sepolia")]
pub fn gas_limit(mut self, gas_limit: u64) -> Self {
self.gas_limit = Some(gas_limit);
self
Expand Down Expand Up @@ -339,6 +367,7 @@ impl NetworkProveBuilder<'_> {
/// let builder = client.prove(&pk, &stdin).min_auction_period(60).run();
/// ```
#[must_use]
#[cfg(feature = "sepolia")]
pub fn min_auction_period(mut self, min_auction_period: u64) -> Self {
self.min_auction_period = min_auction_period;
self
Expand All @@ -365,8 +394,9 @@ impl NetworkProveBuilder<'_> {
/// let builder = client.prove(&pk, &stdin).whitelist(whitelist).run();
/// ```
#[must_use]
#[cfg(feature = "sepolia")]
pub fn whitelist(mut self, whitelist: Vec<Address>) -> Self {
self.whitelist = whitelist;
self.whitelist = Some(whitelist);
self
}

Expand All @@ -391,6 +421,7 @@ impl NetworkProveBuilder<'_> {
/// let builder = client.prove(&pk, &stdin).auctioneer(auctioneer).run();
/// ```
#[must_use]
#[cfg(feature = "sepolia")]
pub fn auctioneer(mut self, auctioneer: Address) -> Self {
self.auctioneer = Some(auctioneer);
self
Expand All @@ -417,6 +448,7 @@ impl NetworkProveBuilder<'_> {
/// let builder = client.prove(&pk, &stdin).executor(executor).run();
/// ```
#[must_use]
#[cfg(feature = "sepolia")]
pub fn executor(mut self, executor: Address) -> Self {
self.executor = Some(executor);
self
Expand All @@ -435,6 +467,7 @@ impl NetworkProveBuilder<'_> {
/// use std::str::FromStr;
/// ```
#[must_use]
#[cfg(feature = "sepolia")]
pub fn verifier(mut self, verifier: Address) -> Self {
self.verifier = Some(verifier);
self
Expand Down Expand Up @@ -463,8 +496,9 @@ impl NetworkProveBuilder<'_> {
/// .unwrap();
/// ```
#[must_use]
pub fn max_price_per_pgu(mut self, max_price_per_pgu: u64) -> Self {
self.max_price_per_pgu = Some(max_price_per_pgu);
#[cfg(feature = "sepolia")]
pub fn max_price_per_gas(mut self, max_price_per_gas: u64) -> Self {
self.max_price_per_gas = Some(max_price_per_gas);
self
}

Expand Down Expand Up @@ -525,7 +559,7 @@ impl NetworkProveBuilder<'_> {
self.auctioneer,
self.executor,
self.verifier,
self.max_price_per_pgu,
self.max_price_per_gas,
)
.await
}
Expand Down Expand Up @@ -594,7 +628,7 @@ impl NetworkProveBuilder<'_> {
self.auctioneer,
self.executor,
self.verifier,
self.max_price_per_pgu,
self.max_price_per_gas,
)
.await
}
Expand Down
Loading
Loading