Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ctian1 committed Jan 10, 2025
1 parent dbe622a commit 1a209d7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 50 deletions.
Binary file modified book/docs/generating-proofs/prover-network/explorer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions book/docs/generating-proofs/prover-network/key-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ cast wallet new

which will give you an output similar to this:

![Screenshot from running 'cast wallet new' to generate an SP1_PRIVATE_KEY.](../prover-network/key.png)
![Screenshot from running 'cast wallet new' to generate a NETWORK_PRIVATE_KEY.](../prover-network/key.png)

The "Address" what you should submit in the [form](https://forms.gle/rTUvhstS8PFfv9B3A), in the example above this is `0x552f0FC6D736ed965CE07a3D71aA639De15B627b`. The "Private key" should be kept safe and
secure. When interacting with the network, you will set your `SP1_PRIVATE_KEY` environment variable
secure. When interacting with the network, you will set your `NETWORK_PRIVATE_KEY` environment variable
to this value.

### Retrieve an Existing Key
Expand Down
63 changes: 15 additions & 48 deletions book/docs/generating-proofs/prover-network/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,70 +14,37 @@ let mut proof = client.prove(&pk, &stdin).run().unwrap();
```

```sh
SP1_PROVER=network SP1_PRIVATE_KEY=... RUST_LOG=info cargo run --release
SP1_PROVER=network NETWORK_PRIVATE_KEY=... RUST_LOG=info cargo run --release
```

- `SP1_PROVER` should be set to `network` when using the prover network.

- `SP1_PRIVATE_KEY` should be set to your [private key](./key-setup.md). You will need
- `NETWORK_PRIVATE_KEY` should be set to your [private key](./key-setup.md). You will need
to be using a [whitelisted](../prover-network) key to use the network.

When you call any of the prove functions in ProverClient now, it will first simulate your program, then wait for it to be proven through the network and finally return the proof.

## View the status of your proof

You can view your proof and other running proofs on the [explorer](https://explorer.succinct.xyz/). The page for your proof will show details such as the stage of your proof and the cycles used. It also shows the program hash which is the keccak256 of the program bytes.
You can view your proof and other running proofs on the [explorer](https://network2.succinct.xyz/). The page for your proof will show details such as the stage of your proof and the cycles used. It also shows the vk hash of the program.

![Screenshot from explorer.succinct.xyz showing the details of a proof including status, stage, type, program, requester, prover, CPU cycles used, time requested, and time claimed.](./explorer.png)
![Screenshot from network2.succinct.xyz showing the details of a proof.](./explorer.png)

## Advanced Usage

### Skip simulation
If you are using the prover network in a production system, or otherwise want to use advanced features such as async, skipping local simulation, or accessing the proof ID, you should use `sp1_sdk::NetworkProver` directly.

To skip the simulation step and directly submit the program for proof generation, you can set the `SKIP_SIMULATION` environment variable to `true`. This will save some time if you are sure that your program is correct. If your program panics, the proof will fail and ProverClient will panic.
```rust,no_run
use sp1_sdk::{network::FulfillmentStrategy, Prover, ProverClient};
use std::time::Duration;
### Use NetworkProver directly
let prover = ProverClient::builder().network().build();
let (pk, vk) = prover.setup(ELF);
By using the `sp1_sdk::NetworkProver` struct directly, you can call async functions directly and have programmatic access to the proof ID and download proofs by ID.
// Request proof
let request_id = prover.prove(&pk, &stdin).groth16().skip_simulation(true).request_async().await.unwrap();
println!("Proof request ID: {}", request_id);
```rust
impl NetworkProver {
/// Creates a new [NetworkProver] with the private key set in `SP1_PRIVATE_KEY`.
pub fn new() -> Self;

/// Creates a new [NetworkProver] with the given private key.
pub fn new_from_key(private_key: &str);

/// Requests a proof from the prover network, returning the proof ID.
pub async fn request_proof(
&self,
elf: &[u8],
stdin: SP1Stdin,
mode: ProofMode,
) -> Result<String>;

/// Waits for a proof to be generated and returns the proof. If a timeout is supplied, the
/// function will return an error if the proof is not generated within the timeout.
pub async fn wait_proof(
&self,
proof_id: &str,
timeout: Option<Duration>,
) -> Result<SP1ProofWithPublicValues>;

/// Get the status and the proof if available of a given proof request. The proof is returned
/// only if the status is Fulfilled.
pub async fn get_proof_status(
&self,
proof_id: &str,
) -> Result<(GetProofStatusResponse, Option<SP1ProofWithPublicValues>)>;

/// Requests a proof from the prover network and waits for it to be generated.
pub async fn prove(
&self,
elf: &[u8],
stdin: SP1Stdin,
mode: ProofMode,
timeout: Option<Duration>,
) -> Result<SP1ProofWithPublicValues>;
}
// Wait for proof complete with a timeout
let proof = prover.wait_proof(request_id, Some(Duration::from_secs(60 * 60))).await.unwrap();
```

0 comments on commit 1a209d7

Please sign in to comment.