Skip to content

Commit

Permalink
chore: update network-v2 proto (#1725)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattstam authored Nov 1, 2024
1 parent eaec49a commit bc92c8b
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 11 deletions.
2 changes: 1 addition & 1 deletion crates/sdk/src/network-v2/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::network_v2::proto::network::{
use crate::network_v2::Signable;

/// The default RPC endpoint for the Succinct prover network.
pub const DEFAULT_PROVER_NETWORK_RPC: &str = "https://rpc.dev.succinct.tools/";
pub const DEFAULT_PROVER_NETWORK_RPC: &str = "https://rpc.production.succinct.tools/";

pub struct NetworkClient {
signer: PrivateKeySigner,
Expand Down
85 changes: 82 additions & 3 deletions crates/sdk/src/network-v2/proto/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,18 @@ pub struct ExecuteProofResponse {
}
#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)]
pub struct ExecuteProofResponseBody {}
#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)]
pub struct GetLatestBridgeBlockRequest {
/// The chain ID of the bridge.
#[prost(uint32, tag = "1")]
pub chain_id: u32,
}
#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)]
pub struct GetLatestBridgeBlockResponse {
/// The latest processed block in the bridge.
#[prost(uint64, tag = "1")]
pub block_number: u64,
}
#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)]
pub struct GetBalanceRequest {
/// The address of the account.
Expand Down Expand Up @@ -447,8 +459,7 @@ impl ExecutionStatus {
/// Generated client implementations.
pub mod prover_network_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::http::Uri;
use tonic::codegen::*;
use tonic::codegen::{http::Uri, *};
#[derive(Debug, Clone)]
pub struct ProverNetworkClient<T> {
inner: tonic::client::Grpc<T>,
Expand Down Expand Up @@ -626,6 +637,26 @@ pub mod prover_network_client {
.insert(GrpcMethod::new("network.ProverNetwork", "GetProofRequestStatus"));
self.inner.unary(req, path, codec).await
}
/// Get the latest processed block in the bridge.
pub async fn get_latest_bridge_block(
&mut self,
request: impl tonic::IntoRequest<super::GetLatestBridgeBlockRequest>,
) -> std::result::Result<tonic::Response<super::GetLatestBridgeBlockResponse>, tonic::Status>
{
self.inner.ready().await.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path =
http::uri::PathAndQuery::from_static("/network.ProverNetwork/GetLatestBridgeBlock");
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("network.ProverNetwork", "GetLatestBridgeBlock"));
self.inner.unary(req, path, codec).await
}
/// Get the balance of an account.
pub async fn get_balance(
&mut self,
Expand Down Expand Up @@ -684,7 +715,8 @@ pub mod prover_network_client {
pub mod prover_network_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
/// Generated trait containing gRPC methods that should be implemented for use with ProverNetworkServer.
/// Generated trait containing gRPC methods that should be implemented for use with
/// ProverNetworkServer.
#[async_trait]
pub trait ProverNetwork: std::marker::Send + std::marker::Sync + 'static {
/// Creates a proof.
Expand Down Expand Up @@ -715,6 +747,11 @@ pub mod prover_network_server {
&self,
request: tonic::Request<super::GetProofRequestStatusRequest>,
) -> std::result::Result<tonic::Response<super::GetProofRequestStatusResponse>, tonic::Status>;
/// Get the latest processed block in the bridge.
async fn get_latest_bridge_block(
&self,
request: tonic::Request<super::GetLatestBridgeBlockRequest>,
) -> std::result::Result<tonic::Response<super::GetLatestBridgeBlockResponse>, tonic::Status>;
/// Get the balance of an account.
async fn get_balance(
&self,
Expand Down Expand Up @@ -1013,6 +1050,48 @@ pub mod prover_network_server {
};
Box::pin(fut)
}
"/network.ProverNetwork/GetLatestBridgeBlock" => {
#[allow(non_camel_case_types)]
struct GetLatestBridgeBlockSvc<T: ProverNetwork>(pub Arc<T>);
impl<T: ProverNetwork>
tonic::server::UnaryService<super::GetLatestBridgeBlockRequest>
for GetLatestBridgeBlockSvc<T>
{
type Response = super::GetLatestBridgeBlockResponse;
type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
fn call(
&mut self,
request: tonic::Request<super::GetLatestBridgeBlockRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as ProverNetwork>::get_latest_bridge_block(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = GetLatestBridgeBlockSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/network.ProverNetwork/GetBalance" => {
#[allow(non_camel_case_types)]
struct GetBalanceSvc<T: ProverNetwork>(pub Arc<T>);
Expand Down
10 changes: 3 additions & 7 deletions crates/sdk/src/network-v2/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
};

use crate::{
network_v2::client::{NetworkClient, DEFAULT_PROVER_NETWORK_RPC},
network_v2::client::NetworkClient,
network_v2::proto::network::{ProofMode, ProofStatus, ProofStrategy},
Prover, SP1Context, SP1ProofKind, SP1ProofWithPublicValues, SP1ProvingKey, SP1VerifyingKey,
};
Expand All @@ -23,8 +23,8 @@ use crate::provers::{CpuProver, ProofOpts, ProverType};
/// The timeout for a proof request to be fulfilled.
const TIMEOUT_SECS: u64 = 14400;

/// The default cycle limit for a proof request.
const DEFAULT_CYCLE_LIMIT: u64 = 1_000_000_000;
/// The default cycle limit for a proof request if simulation is skipped.
const DEFAULT_CYCLE_LIMIT: u64 = 100_000_000;

/// An implementation of [crate::ProverClient] that can generate proofs on a remote RPC server.
pub struct NetworkProver {
Expand Down Expand Up @@ -99,10 +99,6 @@ impl NetworkProver {
let request_id_hex = "0x".to_string() + &hex::encode(request_id.clone());
log::info!("Created request {} in transaction {}", request_id_hex, tx_hash_hex);

if NetworkClient::rpc_url() == DEFAULT_PROVER_NETWORK_RPC {
log::info!("View in explorer: https://explorer-v2.succinct.xyz/{}", request_id_hex);
}

Ok(request_id)
}

Expand Down

0 comments on commit bc92c8b

Please sign in to comment.