Skip to main content

sp1_sdk/network/
mod.rs

1//! # SP1 Network
2//!
3//! A library for interacting with the SP1 prover over the network.
4
5pub mod client;
6pub mod prover;
7#[rustfmt::skip]
8#[allow(missing_docs)]
9#[allow(clippy::default_trait_access)]
10#[allow(clippy::too_many_lines)]
11pub mod proto;
12pub mod builder;
13mod error;
14mod grpc;
15pub mod prove;
16mod retry;
17pub mod signer;
18pub mod tee;
19pub mod validation;
20
21pub mod utils;
22
23use std::time::Duration;
24
25pub use crate::network::{client::NetworkClient, proto::types::FulfillmentStrategy};
26pub use alloy_primitives::{Address, B256};
27pub use error::*;
28pub use utils::{
29    get_default_cycle_limit_for_mode, get_default_rpc_url_for_mode, get_explorer_url_for_mode,
30};
31
32/// The network mode to use for the prover client.
33#[derive(Debug, Clone, Copy, PartialEq, Eq)]
34pub enum NetworkMode {
35    /// Mainnet network using auction-based proving.
36    Mainnet,
37    /// Reserved capacity network for hosted/reserved proving.
38    Reserved,
39}
40
41#[allow(clippy::derivable_impls)]
42impl Default for NetworkMode {
43    fn default() -> Self {
44        cfg_if::cfg_if! {
45            if #[cfg(feature = "reserved-capacity")] {
46                NetworkMode::Reserved
47            } else {
48                NetworkMode::Mainnet
49            }
50        }
51    }
52}
53
54impl std::str::FromStr for NetworkMode {
55    type Err = String;
56
57    fn from_str(s: &str) -> Result<Self, Self::Err> {
58        match s.to_lowercase().as_str() {
59            "mainnet" | "auction" => Ok(NetworkMode::Mainnet),
60            "reserved" | "hosted" => Ok(NetworkMode::Reserved),
61            _ => Err(format!("Invalid network mode: {s}")),
62        }
63    }
64}
65
66pub(crate) const MAINNET_EXPLORER_URL: &str = "https://explorer.succinct.xyz";
67pub(crate) const MAINNET_RPC_URL: &str = "https://rpc.mainnet.succinct.xyz";
68pub(crate) const RESERVED_EXPLORER_URL: &str = "https://explorer.reserved.succinct.xyz";
69pub(crate) const RESERVED_RPC_URL: &str = "https://rpc.production.succinct.xyz";
70
71pub(crate) const PRIVATE_NETWORK_RPC_URL: &str = "https://rpc.private.succinct.xyz";
72pub(crate) const PRIVATE_EXPLORER_URL: &str = "https://explorer-private.succinct.xyz";
73pub(crate) const DEFAULT_TEE_SERVER_URL: &str = "https://tee.production.succinct.xyz";
74pub(crate) const TEE_NETWORK_RPC_URL: &str = "https://tee.sp1-lumiere.xyz";
75
76pub(crate) const DEFAULT_AUCTION_TIMEOUT_DURATION: Duration = Duration::from_secs(30);
77pub(crate) const MAINNET_DEFAULT_CYCLE_LIMIT: u64 = 1_000_000_000_000;
78pub(crate) const RESERVED_DEFAULT_CYCLE_LIMIT: u64 = 100_000_000;
79pub(crate) const DEFAULT_GAS_LIMIT: u64 = 1_000_000_000;
80pub(crate) const DEFAULT_TIMEOUT_SECS: u64 = 14400;