scroll-tech / ceno

Accelerate Zero-knowledge Virtual Machine by Non-uniform Prover Based on GKR Protocol
Apache License 2.0
53 stars 6 forks source link

Deduplicate ceno_zkvm examples #606

Open matthiasgoergens opened 2 days ago

matthiasgoergens commented 2 days ago

We have almost the same code in ceno_zkvm/examples/riscv_opcodes.rs and ceno_zkvm/examples/fibonacci_elf.rs. Let's deduplicate some of that, and make it accessible for other parts of our code base as well.

Eg something like the following would be a useful helper function, instead of copy-and-pasting it wherever we need the functionality:

let halt_record = all_records
    .iter()
    .rev()
    .find(|record| {
        record.insn().codes().kind == EANY
            && record.rs1().unwrap().value == CENO_PLATFORM.ecall_halt()
    })
    .expect("halt record not found");

Look for more instances of these things.