0xEigenLabs / eigen-prover

Eigen zkVM's Proving Service
33 stars 9 forks source link

Refactor pipeline with powdr pipeline #54

Closed eigmax closed 7 months ago

eigmax commented 7 months ago

In eigen-prover's pipeline, the diagram looks like this:

graph TD;
    Node-- produce the chunks sequentially --->Executor;
    Node-- prove each chunks parallellly --->Prover;

In powdr's pipeline, the stage of Node --> Executor:

let (trace, _mem) = riscv_executor::execute::<GoldilocksField>(
        &asm_contents,
        mk_pipeline_with_data().data_callback().unwrap(),
        &default_input(&[]),
        riscv_executor::ExecMode::Fast,
        );

log::info!("Running powdr-riscv executor in trace mode for continuations...");
let start = Instant::now();
let bootloader_inputs = rust_continuations_dry_run(mk_pipeline_with_data());
let duration = start.elapsed();
log::info!("Trace executor took: {:?}", duration);

Then we can get the chunks info from bootloader_inputs and distribute them into different provers.

the Node --> Prover:

let prove_with = Some(BackendType::EStark);
let generate_witness_and_prove =
|mut pipeline: Pipeline<GoldilocksField>| -> Result<(), Vec<String>> {
    let start = Instant::now();
    log::debug!("Generating witness...");
    pipeline.advance_to(Stage::GeneratedWitness)?;
    let duration = start.elapsed();
    log::debug!("Generating witness took: {:?}", duration);

    let start = Instant::now();
    log::debug!("Proving ...");
    prove_with.map(|backend| pipeline.with_backend(backend).proof().unwrap());
    let duration = start.elapsed();
    log::debug!("Proving took: {:?}", duration);
    Ok(())
};

log::info!("Running witness generation...");
let start = Instant::now();
rust_continuations(mk_pipeline_opt, generate_witness_and_prove, bootloader_inputs).unwrap();
let duration = start.elapsed();
log::info!("Witness generation took: {:?}", duration);