mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-05-01 07:43:16 +00:00
58 lines
1.8 KiB
Rust
58 lines
1.8 KiB
Rust
|
|
use plonky2::field::extension::Extendable;
|
||
|
|
use plonky2::field::polynomial::PolynomialValues;
|
||
|
|
use plonky2::field::types::Field;
|
||
|
|
use plonky2::hash::hash_types::RichField;
|
||
|
|
|
||
|
|
use crate::all_stark::AllStark;
|
||
|
|
use crate::cpu::bootstrap_kernel::generate_bootstrap_kernel;
|
||
|
|
use crate::cpu::columns::NUM_CPU_COLUMNS;
|
||
|
|
use crate::generation::state::GenerationState;
|
||
|
|
use crate::util::trace_rows_to_poly_values;
|
||
|
|
|
||
|
|
mod memory;
|
||
|
|
pub(crate) mod state;
|
||
|
|
|
||
|
|
pub type RlpMerkleProof = Vec<Vec<u8>>;
|
||
|
|
|
||
|
|
#[allow(unused)] // TODO: Should be used soon.
|
||
|
|
pub struct TransactionData {
|
||
|
|
pub(crate) payload: Vec<u8>,
|
||
|
|
pub(crate) signature: Vec<u8>,
|
||
|
|
/// A Merkle proof for each interaction with the state trie, ordered chronologically.
|
||
|
|
pub(crate) trie_proofs: Vec<RlpMerkleProof>,
|
||
|
|
}
|
||
|
|
|
||
|
|
#[allow(unused)] // TODO: Should be used soon.
|
||
|
|
fn generate_traces<F: RichField + Extendable<D>, const D: usize>(
|
||
|
|
all_stark: &AllStark<F, D>,
|
||
|
|
txns: &[TransactionData],
|
||
|
|
) -> Vec<Vec<PolynomialValues<F>>> {
|
||
|
|
let mut state = GenerationState::<F>::default();
|
||
|
|
|
||
|
|
generate_bootstrap_kernel::<F>(&mut state);
|
||
|
|
|
||
|
|
for txn in txns {
|
||
|
|
generate_txn(&mut state, txn);
|
||
|
|
}
|
||
|
|
|
||
|
|
let GenerationState {
|
||
|
|
cpu_rows,
|
||
|
|
current_cpu_row,
|
||
|
|
memory,
|
||
|
|
keccak_inputs,
|
||
|
|
logic_ops: logic_inputs,
|
||
|
|
..
|
||
|
|
} = state;
|
||
|
|
assert_eq!(current_cpu_row, [F::ZERO; NUM_CPU_COLUMNS]);
|
||
|
|
|
||
|
|
let cpu_trace = trace_rows_to_poly_values(cpu_rows);
|
||
|
|
let keccak_trace = all_stark.keccak_stark.generate_trace(keccak_inputs);
|
||
|
|
let logic_trace = all_stark.logic_stark.generate_trace(logic_inputs);
|
||
|
|
let memory_trace = all_stark.memory_stark.generate_trace(memory.log);
|
||
|
|
vec![cpu_trace, keccak_trace, logic_trace, memory_trace]
|
||
|
|
}
|
||
|
|
|
||
|
|
fn generate_txn<F: Field>(_state: &mut GenerationState<F>, _txn: &TransactionData) {
|
||
|
|
todo!()
|
||
|
|
}
|