Skip to content

Commit

Permalink
add just reciple
Browse files Browse the repository at this point in the history
  • Loading branch information
leruaa committed Jan 15, 2025
1 parent a905c1f commit b682a82
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pgo-data.profdata
# Proofs
**/proof-with-pis.json
**/proof-with-io.json
latest_proof.json

# Env
.env
Expand Down
29 changes: 29 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,32 @@ run-blocks start_block end_block chain_id:
trace-block block chain_id:
TRACE_FILE=trace_$block_$chain_id.log cargo run --release --bin rsp -- --block-number "$block_number" --chain-id {{chain_id}}
cargo prove --trace

# Recipe to run the rsp CLI on the latest block in a loop at the given interval and submit proving times to ETH proofs.
run-eth-proofs cluster_id="1" sleep_time="900":
#!/usr/bin/env bash
while true; do
RESPONSE=$(curl -s \
-X POST \
-H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
"$RPC_URL")
BLOCK_NUMBER=$((16#$(echo $RESPONSE | grep -o '"result":"[^"]*"' | cut -d'"' -f4 | sed 's/0x//')))
echo "Latest block number: $BLOCK_NUMBER"

ROUNDED_BLOCK=$((BLOCK_NUMBER - (BLOCK_NUMBER % 100)))
echo "Rounded block number: $ROUNDED_BLOCK"

echo "Running rsp..."
SP1_PROVER=cuda cargo run --bin rsp --release -F cuda -- --block-number $ROUNDED_BLOCK --eth-proofs-cluster-id {{cluster_id}} --rpc-url $RPC_URL --prove

echo "Sleeping for $(({{sleep_time}} / 60)) minutes..."
sleep $sleep_time
done

# Usage:
# just run-eth-proofs <cluster-id> <sleep-time>

# Example:
# just run-eth-proofs 5 600
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,32 @@ To generate proofs locally on a GPU, you can enable the `cuda` feature in the CL
cargo run --bin rsp --release --features cuda -- --block-number 18884864 --chain-id <chain-id> --prove
```

#### Benchmarking on ETH proofs

To run benchmarking with [ETH proofs](https://staging--ethproofs.netlify.app/), you'll need to:

1. Set the following environment variables:
```bash
export ETH_PROOFS_ENDPOINT="https://staging--ethproofs.netlify.app/api/v0"
export ETH_PROOFS_API_TOKEN=<your_api_token>
export RPC_URL=<your_eth_mainnet_rpc>
```

3. Run the benchmarking recipe:
```bash
# Run with default cluster ID (1) and sleep time (900s)
just run-eth-proofs

# Run with custom cluster ID and sleep time (in seconds)
just run-eth-proofs 5 600
```

This will continuously:
- Fetch the latest block number
- Round it down to the nearest 100
- Generate a proof and submit its proving time
- Sleep for the specified duration before the next iteration

## FAQ

### Building the client programs manually
Expand Down
6 changes: 3 additions & 3 deletions bin/host/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct HostArgs {
eth_proofs_api_token: Option<String>,

/// Optional ETH proofs cluster ID.
#[clap(long, env, default_value_t = 1)]
#[clap(long, default_value_t = 1)]
eth_proofs_cluster_id: u64,
}

Expand Down Expand Up @@ -154,8 +154,8 @@ async fn main() -> eyre::Result<()> {
}

let start = std::time::Instant::now();
//let proof = client.prove(&pk, &stdin).compressed().run().expect("Proving should work.");
let proof_bytes = vec![2; 10]; // bincode::serialize(&proof.proof).unwrap();
let proof = client.prove(&pk, &stdin).compressed().run().expect("Proving should work.");
let proof_bytes = bincode::serialize(&proof.proof).unwrap();
let elapsed = start.elapsed().as_secs_f32();

if let Some(eth_proofs_client) = &eth_proofs_client {
Expand Down

0 comments on commit b682a82

Please sign in to comment.