Batch Processing Example

Process large transaction batches efficiently.

This example shows how to process large volumes of transactions in fixed-size batches while producing one proof per batch.

Full example

RUST
use fairseq_sdk::{Config, Prover, Transaction, Proof};

pub async fn process_batches(
    prover: &Prover,
    transactions: Vec<Transaction>,
    batch_size: usize,
) -> Result<Vec<Proof>, Box<dyn std::error::Error>> {
    let mut proofs = Vec::new();

    for batch in transactions.chunks(batch_size) {
        let proof = prover.prove(batch.to_vec()).await?;
        proofs.push(proof);
    }

    Ok(proofs)
}

Suggested batch sizes

ScenarioRecommended Batch Size
DEX trades100-500
L2 sequencer500-1000
High-frequency50-100

Operational tips

  • Maintain stable ordering inputs (hash + ingress time).
  • Persist proof metadata with batch IDs.
  • Apply backpressure if proof latency increases.
Was this page helpful? /
Back to docs