Skip to content

Commit

Permalink
feat(sdk): add explorer link (#858)
Browse files Browse the repository at this point in the history
  • Loading branch information
ctian1 authored Jun 1, 2024
1 parent ce2cf6b commit 20e36b7
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion prover/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-plonk-bn254:
rm -rf build && \
mkdir -p build && \
RUSTFLAGS='-C target-cpu=native' \
cargo run -p sp1-prover --release --bin build_plonk_bn254 -- \
cargo run -p sp1-prover --release --bin build_plonk_bn254 --features plonk -- \
--build-dir=./build

release-plonk-bn254:
Expand Down
2 changes: 2 additions & 0 deletions recursion/gnark-ffi/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(unused)]

use cfg_if::cfg_if;
use std::env;
use std::path::PathBuf;
Expand Down
2 changes: 2 additions & 0 deletions recursion/gnark-ffi/src/ffi.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(unused)]

//! FFI bindings for the Go code. The functions exported in this module are safe to call from Rust.
//! All C strings and other C memory should be freed in Rust, including C Strings returned by Go.
//! Although we cast to *mut c_char because the Go signatures can't be immutable, the Go functions
Expand Down
10 changes: 6 additions & 4 deletions sdk/src/network/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::proto::network::{
};

/// The default RPC endpoint for the Succinct prover network.
const DEFAULT_PROVER_NETWORK_RPC: &str = "https://rpc.succinct.xyz/";
pub 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";
Expand All @@ -37,19 +37,21 @@ pub struct NetworkClient {
}

impl NetworkClient {
pub fn rpc_url() -> String {
env::var("PROVER_NETWORK_RPC").unwrap_or_else(|_| DEFAULT_PROVER_NETWORK_RPC.to_string())
}

// Create a new NetworkClient with the given private key for authentication.
pub fn new(private_key: &str) -> Self {
let auth = NetworkAuth::new(private_key);

let rpc_url = env::var("PROVER_NETWORK_RPC")
.unwrap_or_else(|_| DEFAULT_PROVER_NETWORK_RPC.to_string());

let twirp_http_client = HttpClient::builder()
.pool_max_idle_per_host(0)
.pool_idle_timeout(Duration::from_secs(240))
.build()
.unwrap();

let rpc_url = Self::rpc_url();
let rpc =
TwirpClient::new(Url::parse(&rpc_url).unwrap(), twirp_http_client, vec![]).unwrap();

Expand Down
14 changes: 10 additions & 4 deletions sdk/src/network/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{env, time::Duration};

use crate::proto::network::ProofMode;
use crate::{
network::client::NetworkClient,
network::client::{NetworkClient, DEFAULT_PROVER_NETWORK_RPC},
proto::network::{ProofStatus, TransactionStatus},
Prover,
};
Expand Down Expand Up @@ -62,6 +62,13 @@ impl NetworkProver {
let proof_id = client.create_proof(elf, &stdin, mode, version).await?;
log::info!("Created {}", proof_id);

if NetworkClient::rpc_url() == DEFAULT_PROVER_NETWORK_RPC {
log::info!(
"View in explorer: https://explorer.succinct.xyz/{}",
proof_id.split('_').last().unwrap_or(&proof_id)
);
}

let mut is_claimed = false;
loop {
let (status, maybe_proof) = client.get_proof_status::<P>(&proof_id).await?;
Expand All @@ -82,10 +89,9 @@ impl NetworkProver {
status.unclaim_description()
));
}
_ => {
sleep(Duration::from_secs(1)).await;
}
_ => {}
}
sleep(Duration::from_secs(2)).await;
}
}

Expand Down
6 changes: 3 additions & 3 deletions sdk/src/proto/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ impl ProofMode {
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub const fn as_str_name(&self) -> &'static str {
pub fn as_str_name(&self) -> &'static str {
match self {
ProofMode::Unspecified => "PROOF_MODE_UNSPECIFIED",
ProofMode::Core => "PROOF_MODE_CORE",
Expand Down Expand Up @@ -365,7 +365,7 @@ impl ProofStatus {
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub const fn as_str_name(&self) -> &'static str {
pub fn as_str_name(&self) -> &'static str {
match self {
ProofStatus::ProofUnspecifiedStatus => "PROOF_UNSPECIFIED_STATUS",
ProofStatus::ProofPreparing => "PROOF_PREPARING",
Expand Down Expand Up @@ -422,7 +422,7 @@ impl TransactionStatus {
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub const fn as_str_name(&self) -> &'static str {
pub fn as_str_name(&self) -> &'static str {
match self {
TransactionStatus::TransactionUnspecifiedStatus => "TRANSACTION_UNSPECIFIED_STATUS",
TransactionStatus::TransactionScheduled => "TRANSACTION_SCHEDULED",
Expand Down
1 change: 1 addition & 0 deletions sdk/src/provers/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ impl Prover for LocalProver {
})
}

#[allow(unused)]
fn prove_plonk(&self, pk: &SP1ProvingKey, stdin: SP1Stdin) -> Result<SP1PlonkBn254Proof> {
cfg_if! {
if #[cfg(feature = "plonk")] {
Expand Down

0 comments on commit 20e36b7

Please sign in to comment.