From 88fcc329835672367a3c6aa97852b7487ee53695 Mon Sep 17 00:00:00 2001 From: Robin Salen <30937548+Nashtare@users.noreply.github.com> Date: Mon, 13 Nov 2023 09:26:56 -0500 Subject: [PATCH] Reduce visibility for a bunch of structs and methods in EVM crate (#1289) * Reduce visibility for a bunch of structs and methods * Remove redundant --- evm/src/all_stark.rs | 16 ++-- evm/src/arithmetic/arithmetic_stark.rs | 2 +- evm/src/byte_packing/byte_packing_stark.rs | 4 +- evm/src/constraint_consumer.rs | 24 ++--- evm/src/cpu/columns/mod.rs | 4 +- evm/src/cpu/columns/ops.rs | 2 +- evm/src/cpu/contextops.rs | 4 +- evm/src/cpu/control_flow.rs | 4 +- evm/src/cpu/cpu_stark.rs | 28 +++--- evm/src/cpu/decode.rs | 4 +- evm/src/cpu/dup_swap.rs | 4 +- evm/src/cpu/gas.rs | 4 +- evm/src/cpu/halt.rs | 4 +- evm/src/cpu/jumps.rs | 12 +-- evm/src/cpu/kernel/constants/journal_entry.rs | 1 - evm/src/cpu/kernel/constants/mod.rs | 2 +- evm/src/cpu/kernel/constants/txn_fields.rs | 1 - evm/src/cpu/kernel/interpreter.rs | 12 +-- evm/src/cpu/kernel/parser.rs | 2 +- evm/src/cpu/kernel/stack/permutations.rs | 4 +- evm/src/cpu/kernel/tests/receipt.rs | 2 +- evm/src/cpu/membus.rs | 4 +- evm/src/cpu/memio.rs | 4 +- evm/src/cpu/modfp254.rs | 4 +- evm/src/cpu/pc.rs | 4 +- evm/src/cpu/push0.rs | 4 +- evm/src/cpu/simple_logic/eq_iszero.rs | 6 +- evm/src/cpu/simple_logic/mod.rs | 4 +- evm/src/cpu/simple_logic/not.rs | 4 +- evm/src/cpu/stack.rs | 4 +- evm/src/cpu/stack_bounds.rs | 4 +- evm/src/cpu/syscalls_exceptions.rs | 4 +- evm/src/cross_table_lookup.rs | 68 +++++++------- evm/src/curve_pairings.rs | 20 ++--- evm/src/extension_tower.rs | 18 ++-- evm/src/fixed_recursive_verifier.rs | 30 +++---- evm/src/generation/state.rs | 10 +-- evm/src/keccak/columns.rs | 2 +- evm/src/keccak/keccak_stark.rs | 12 +-- evm/src/keccak_sponge/keccak_sponge_stark.rs | 2 +- evm/src/lib.rs | 5 +- evm/src/logic.rs | 10 ++- evm/src/lookup.rs | 4 +- evm/src/memory/memory_stark.rs | 10 ++- evm/src/memory/segments.rs | 2 - evm/src/proof.rs | 88 +++++++++---------- evm/src/recursive_verifier.rs | 4 +- evm/src/stark_testing.rs | 8 +- evm/src/util.rs | 9 +- evm/src/witness/errors.rs | 1 - evm/src/witness/memory.rs | 18 ++-- evm/src/witness/traces.rs | 36 ++++---- 52 files changed, 278 insertions(+), 265 deletions(-) diff --git a/evm/src/all_stark.rs b/evm/src/all_stark.rs index 50d3268883..4b95e883d0 100644 --- a/evm/src/all_stark.rs +++ b/evm/src/all_stark.rs @@ -26,14 +26,14 @@ use crate::stark::Stark; /// Structure containing all STARKs and the cross-table lookups. #[derive(Clone)] pub struct AllStark, const D: usize> { - pub arithmetic_stark: ArithmeticStark, - pub byte_packing_stark: BytePackingStark, - pub cpu_stark: CpuStark, - pub keccak_stark: KeccakStark, - pub keccak_sponge_stark: KeccakSpongeStark, - pub logic_stark: LogicStark, - pub memory_stark: MemoryStark, - pub cross_table_lookups: Vec>, + pub(crate) arithmetic_stark: ArithmeticStark, + pub(crate) byte_packing_stark: BytePackingStark, + pub(crate) cpu_stark: CpuStark, + pub(crate) keccak_stark: KeccakStark, + pub(crate) keccak_sponge_stark: KeccakSpongeStark, + pub(crate) logic_stark: LogicStark, + pub(crate) memory_stark: MemoryStark, + pub(crate) cross_table_lookups: Vec>, } impl, const D: usize> Default for AllStark { diff --git a/evm/src/arithmetic/arithmetic_stark.rs b/evm/src/arithmetic/arithmetic_stark.rs index 14544654eb..8072673cfc 100644 --- a/evm/src/arithmetic/arithmetic_stark.rs +++ b/evm/src/arithmetic/arithmetic_stark.rs @@ -116,7 +116,7 @@ pub(crate) fn ctl_arithmetic_rows() -> TableWithColumns { /// Structure representing the `Arithmetic` STARK, which carries out all the arithmetic operations. #[derive(Copy, Clone, Default)] -pub struct ArithmeticStark { +pub(crate) struct ArithmeticStark { pub f: PhantomData, } diff --git a/evm/src/byte_packing/byte_packing_stark.rs b/evm/src/byte_packing/byte_packing_stark.rs index ad485c591e..5b3c44911a 100644 --- a/evm/src/byte_packing/byte_packing_stark.rs +++ b/evm/src/byte_packing/byte_packing_stark.rs @@ -91,7 +91,7 @@ pub(crate) fn ctl_looked_data() -> Vec> { } /// CTL filter for the `BytePackingStark` looked table. -pub fn ctl_looked_filter() -> Column { +pub(crate) fn ctl_looked_filter() -> Column { // The CPU table is only interested in our sequence end rows, // since those contain the final limbs of our packed int. Column::single(SEQUENCE_END) @@ -136,7 +136,7 @@ pub(crate) struct BytePackingOp { } #[derive(Copy, Clone, Default)] -pub struct BytePackingStark { +pub(crate) struct BytePackingStark { pub(crate) f: PhantomData, } diff --git a/evm/src/constraint_consumer.rs b/evm/src/constraint_consumer.rs index 49dc018ce3..470e2db218 100644 --- a/evm/src/constraint_consumer.rs +++ b/evm/src/constraint_consumer.rs @@ -29,7 +29,7 @@ pub struct ConstraintConsumer { } impl ConstraintConsumer

{ - pub fn new( + pub(crate) fn new( alphas: Vec, z_last: P, lagrange_basis_first: P, @@ -44,17 +44,17 @@ impl ConstraintConsumer

{ } } - pub fn accumulators(self) -> Vec

{ + pub(crate) fn accumulators(self) -> Vec

{ self.constraint_accs } /// Add one constraint valid on all rows except the last. - pub fn constraint_transition(&mut self, constraint: P) { + pub(crate) fn constraint_transition(&mut self, constraint: P) { self.constraint(constraint * self.z_last); } /// Add one constraint on all rows. - pub fn constraint(&mut self, constraint: P) { + pub(crate) fn constraint(&mut self, constraint: P) { for (&alpha, acc) in self.alphas.iter().zip(&mut self.constraint_accs) { *acc *= alpha; *acc += constraint; @@ -63,13 +63,13 @@ impl ConstraintConsumer

{ /// Add one constraint, but first multiply it by a filter such that it will only apply to the /// first row of the trace. - pub fn constraint_first_row(&mut self, constraint: P) { + pub(crate) fn constraint_first_row(&mut self, constraint: P) { self.constraint(constraint * self.lagrange_basis_first); } /// Add one constraint, but first multiply it by a filter such that it will only apply to the /// last row of the trace. - pub fn constraint_last_row(&mut self, constraint: P) { + pub(crate) fn constraint_last_row(&mut self, constraint: P) { self.constraint(constraint * self.lagrange_basis_last); } } @@ -96,7 +96,7 @@ pub struct RecursiveConstraintConsumer, const D: us } impl, const D: usize> RecursiveConstraintConsumer { - pub fn new( + pub(crate) fn new( zero: ExtensionTarget, alphas: Vec, z_last: ExtensionTarget, @@ -113,12 +113,12 @@ impl, const D: usize> RecursiveConstraintConsumer Vec> { + pub(crate) fn accumulators(self) -> Vec> { self.constraint_accs } /// Add one constraint valid on all rows except the last. - pub fn constraint_transition( + pub(crate) fn constraint_transition( &mut self, builder: &mut CircuitBuilder, constraint: ExtensionTarget, @@ -128,7 +128,7 @@ impl, const D: usize> RecursiveConstraintConsumer, constraint: ExtensionTarget, @@ -140,7 +140,7 @@ impl, const D: usize> RecursiveConstraintConsumer, constraint: ExtensionTarget, @@ -151,7 +151,7 @@ impl, const D: usize> RecursiveConstraintConsumer, constraint: ExtensionTarget, diff --git a/evm/src/cpu/columns/mod.rs b/evm/src/cpu/columns/mod.rs index f83147c2dc..72571e5ee3 100644 --- a/evm/src/cpu/columns/mod.rs +++ b/evm/src/cpu/columns/mod.rs @@ -21,7 +21,7 @@ pub type MemValue = [T; memory::VALUE_LIMBS]; /// View of the columns required for one memory channel. #[repr(C)] #[derive(Clone, Copy, Debug, Eq, PartialEq)] -pub struct MemoryChannelView { +pub(crate) struct MemoryChannelView { /// 1 if this row includes a memory operation in the `i`th channel of the memory bus, otherwise /// 0. pub used: T, @@ -40,7 +40,7 @@ pub struct MemoryChannelView { /// View of all the columns in `CpuStark`. #[repr(C)] #[derive(Clone, Copy, Eq, PartialEq, Debug)] -pub struct CpuColumnsView { +pub(crate) struct CpuColumnsView { /// Filter. 1 if the row is part of bootstrapping the kernel code, 0 otherwise. pub is_bootstrap_kernel: T, diff --git a/evm/src/cpu/columns/ops.rs b/evm/src/cpu/columns/ops.rs index 282fa393e2..c3b1e2641e 100644 --- a/evm/src/cpu/columns/ops.rs +++ b/evm/src/cpu/columns/ops.rs @@ -7,7 +7,7 @@ use crate::util::transmute_no_compile_time_size_checks; /// Structure representing the flags for the various opcodes. #[repr(C)] #[derive(Clone, Copy, Eq, PartialEq, Debug)] -pub struct OpsColumnsView { +pub(crate) struct OpsColumnsView { /// Combines ADD, MUL, SUB, DIV, MOD, LT, GT and BYTE flags. pub binary_op: T, /// Combines ADDMOD, MULMOD and SUBMOD flags. diff --git a/evm/src/cpu/contextops.rs b/evm/src/cpu/contextops.rs index 8e25d5a168..1fe6434e5e 100644 --- a/evm/src/cpu/contextops.rs +++ b/evm/src/cpu/contextops.rs @@ -337,7 +337,7 @@ fn eval_ext_circuit_set, const D: usize>( } /// Evaluates the constraints for the GET and SET opcodes. -pub fn eval_packed( +pub(crate) fn eval_packed( lv: &CpuColumnsView

, nv: &CpuColumnsView

, yield_constr: &mut ConstraintConsumer

, @@ -376,7 +376,7 @@ pub fn eval_packed( /// Circuit version of èval_packed`. /// Evaluates the constraints for the GET and SET opcodes. -pub fn eval_ext_circuit, const D: usize>( +pub(crate) fn eval_ext_circuit, const D: usize>( builder: &mut CircuitBuilder, lv: &CpuColumnsView>, nv: &CpuColumnsView>, diff --git a/evm/src/cpu/control_flow.rs b/evm/src/cpu/control_flow.rs index adaee51123..d92301317c 100644 --- a/evm/src/cpu/control_flow.rs +++ b/evm/src/cpu/control_flow.rs @@ -43,7 +43,7 @@ pub(crate) fn get_start_pc() -> F { } /// Evaluates the constraints related to the flow of instructions. -pub fn eval_packed_generic( +pub(crate) fn eval_packed_generic( lv: &CpuColumnsView

, nv: &CpuColumnsView

, yield_constr: &mut ConstraintConsumer

, @@ -83,7 +83,7 @@ pub fn eval_packed_generic( /// Circuit version of `eval_packed`. /// Evaluates the constraints related to the flow of instructions. -pub fn eval_ext_circuit, const D: usize>( +pub(crate) fn eval_ext_circuit, const D: usize>( builder: &mut plonky2::plonk::circuit_builder::CircuitBuilder, lv: &CpuColumnsView>, nv: &CpuColumnsView>, diff --git a/evm/src/cpu/cpu_stark.rs b/evm/src/cpu/cpu_stark.rs index 4dc23b2a35..f63e90e18d 100644 --- a/evm/src/cpu/cpu_stark.rs +++ b/evm/src/cpu/cpu_stark.rs @@ -26,7 +26,7 @@ use crate::stark::Stark; /// Creates the vector of `Columns` corresponding to the General Purpose channels when calling the Keccak sponge: /// the CPU reads the output of the sponge directly from the `KeccakSpongeStark` table. -pub fn ctl_data_keccak_sponge() -> Vec> { +pub(crate) fn ctl_data_keccak_sponge() -> Vec> { // When executing KECCAK_GENERAL, the GP memory channels are used as follows: // GP channel 0: stack[-1] = context // GP channel 1: stack[-2] = segment @@ -47,7 +47,7 @@ pub fn ctl_data_keccak_sponge() -> Vec> { } /// CTL filter for a call to the Keccak sponge. -pub fn ctl_filter_keccak_sponge() -> Column { +pub(crate) fn ctl_filter_keccak_sponge() -> Column { Column::single(COL_MAP.is_keccak_sponge) } @@ -73,7 +73,7 @@ fn ctl_data_ternops() -> Vec> { } /// Creates the vector of columns corresponding to the opcode, the two inputs and the output of the logic operation. -pub fn ctl_data_logic() -> Vec> { +pub(crate) fn ctl_data_logic() -> Vec> { // Instead of taking single columns, we reconstruct the entire opcode value directly. let mut res = vec![Column::le_bits(COL_MAP.opcode_bits)]; res.extend(ctl_data_binops()); @@ -81,12 +81,12 @@ pub fn ctl_data_logic() -> Vec> { } /// CTL filter for logic operations. -pub fn ctl_filter_logic() -> Column { +pub(crate) fn ctl_filter_logic() -> Column { Column::single(COL_MAP.op.logic_op) } /// Returns the `TableWithColumns` for the CPU rows calling arithmetic operations. -pub fn ctl_arithmetic_base_rows() -> TableWithColumns { +pub(crate) fn ctl_arithmetic_base_rows() -> TableWithColumns { // Instead of taking single columns, we reconstruct the entire opcode value directly. let mut columns = vec![Column::le_bits(COL_MAP.opcode_bits)]; columns.extend(ctl_data_ternops()); @@ -112,17 +112,17 @@ pub fn ctl_arithmetic_base_rows() -> TableWithColumns { /// Creates the vector of `Columns` corresponding to the contents of General Purpose channels when calling byte packing. /// We use `ctl_data_keccak_sponge` because the `Columns` are the same as the ones computed for `KeccakSpongeStark`. -pub fn ctl_data_byte_packing() -> Vec> { +pub(crate) fn ctl_data_byte_packing() -> Vec> { ctl_data_keccak_sponge() } /// CTL filter for the `MLOAD_32BYTES` operation. -pub fn ctl_filter_byte_packing() -> Column { +pub(crate) fn ctl_filter_byte_packing() -> Column { Column::single(COL_MAP.op.mload_32bytes) } /// Creates the vector of `Columns` corresponding to the contents of General Purpose channels when calling byte unpacking. -pub fn ctl_data_byte_unpacking() -> Vec> { +pub(crate) fn ctl_data_byte_unpacking() -> Vec> { // When executing MSTORE_32BYTES, the GP memory channels are used as follows: // GP channel 0: stack[-1] = context // GP channel 1: stack[-2] = segment @@ -145,7 +145,7 @@ pub fn ctl_data_byte_unpacking() -> Vec> { } /// CTL filter for the `MSTORE_32BYTES` operation. -pub fn ctl_filter_byte_unpacking() -> Column { +pub(crate) fn ctl_filter_byte_unpacking() -> Column { Column::single(COL_MAP.op.mstore_32bytes) } @@ -162,7 +162,7 @@ fn mem_time_and_channel(channel: usize) -> Column { } /// Creates the vector of `Columns` corresponding to the contents of the code channel when reading code values. -pub fn ctl_data_code_memory() -> Vec> { +pub(crate) fn ctl_data_code_memory() -> Vec> { let mut cols = vec![ Column::constant(F::ONE), // is_read Column::single(COL_MAP.code_context), // addr_context @@ -182,7 +182,7 @@ pub fn ctl_data_code_memory() -> Vec> { } /// Creates the vector of `Columns` corresponding to the contents of General Purpose channels. -pub fn ctl_data_gp_memory(channel: usize) -> Vec> { +pub(crate) fn ctl_data_gp_memory(channel: usize) -> Vec> { let channel_map = COL_MAP.mem_channels[channel]; let mut cols: Vec<_> = Column::singles([ channel_map.is_read, @@ -200,18 +200,18 @@ pub fn ctl_data_gp_memory(channel: usize) -> Vec> { } /// CTL filter for code read and write operations. -pub fn ctl_filter_code_memory() -> Column { +pub(crate) fn ctl_filter_code_memory() -> Column { Column::sum(COL_MAP.op.iter()) } /// CTL filter for General Purpose memory read and write operations. -pub fn ctl_filter_gp_memory(channel: usize) -> Column { +pub(crate) fn ctl_filter_gp_memory(channel: usize) -> Column { Column::single(COL_MAP.mem_channels[channel].used) } /// Structure representing the CPU Stark. #[derive(Copy, Clone, Default)] -pub struct CpuStark { +pub(crate) struct CpuStark { pub f: PhantomData, } diff --git a/evm/src/cpu/decode.rs b/evm/src/cpu/decode.rs index 77246aea8d..449030fa79 100644 --- a/evm/src/cpu/decode.rs +++ b/evm/src/cpu/decode.rs @@ -74,7 +74,7 @@ const fn bits_from_opcode(opcode: u8) -> [bool; 8] { } /// Evaluates the constraints for opcode decoding. -pub fn eval_packed_generic( +pub(crate) fn eval_packed_generic( lv: &CpuColumnsView

, yield_constr: &mut ConstraintConsumer

, ) { @@ -181,7 +181,7 @@ pub fn eval_packed_generic( /// Circuit version of `eval_packed_generic`. /// Evaluates the constraints for opcode decoding. -pub fn eval_ext_circuit, const D: usize>( +pub(crate) fn eval_ext_circuit, const D: usize>( builder: &mut plonky2::plonk::circuit_builder::CircuitBuilder, lv: &CpuColumnsView>, yield_constr: &mut RecursiveConstraintConsumer, diff --git a/evm/src/cpu/dup_swap.rs b/evm/src/cpu/dup_swap.rs index fd623c7ee6..2ab6435237 100644 --- a/evm/src/cpu/dup_swap.rs +++ b/evm/src/cpu/dup_swap.rs @@ -323,7 +323,7 @@ fn eval_ext_circuit_swap, const D: usize>( } /// Evaluates the constraints for the DUP and SWAP opcodes. -pub fn eval_packed( +pub(crate) fn eval_packed( lv: &CpuColumnsView

, nv: &CpuColumnsView

, yield_constr: &mut ConstraintConsumer

, @@ -339,7 +339,7 @@ pub fn eval_packed( /// Circuit version of `eval_packed`. /// Evaluates the constraints for the DUP and SWAP opcodes. -pub fn eval_ext_circuit, const D: usize>( +pub(crate) fn eval_ext_circuit, const D: usize>( builder: &mut CircuitBuilder, lv: &CpuColumnsView>, nv: &CpuColumnsView>, diff --git a/evm/src/cpu/gas.rs b/evm/src/cpu/gas.rs index ed0f33b487..db4e99415c 100644 --- a/evm/src/cpu/gas.rs +++ b/evm/src/cpu/gas.rs @@ -134,7 +134,7 @@ fn eval_packed_init( } /// Evaluate the gas constraints for the opcodes that cost a constant gas. -pub fn eval_packed( +pub(crate) fn eval_packed( lv: &CpuColumnsView

, nv: &CpuColumnsView

, yield_constr: &mut ConstraintConsumer

, @@ -300,7 +300,7 @@ fn eval_ext_circuit_init, const D: usize>( /// Circuit version of `eval_packed`. /// Evaluate the gas constraints for the opcodes that cost a constant gas. -pub fn eval_ext_circuit, const D: usize>( +pub(crate) fn eval_ext_circuit, const D: usize>( builder: &mut plonky2::plonk::circuit_builder::CircuitBuilder, lv: &CpuColumnsView>, nv: &CpuColumnsView>, diff --git a/evm/src/cpu/halt.rs b/evm/src/cpu/halt.rs index 8ed9aa5bcd..4961f60d20 100644 --- a/evm/src/cpu/halt.rs +++ b/evm/src/cpu/halt.rs @@ -12,7 +12,7 @@ use crate::cpu::columns::{CpuColumnsView, COL_MAP}; use crate::cpu::membus::NUM_GP_CHANNELS; /// Evaluates constraints for the `halt` flag. -pub fn eval_packed( +pub(crate) fn eval_packed( lv: &CpuColumnsView

, nv: &CpuColumnsView

, yield_constr: &mut ConstraintConsumer

, @@ -48,7 +48,7 @@ pub fn eval_packed( /// Circuit version of `eval_packed`. /// Evaluates constraints for the `halt` flag. -pub fn eval_ext_circuit, const D: usize>( +pub(crate) fn eval_ext_circuit, const D: usize>( builder: &mut plonky2::plonk::circuit_builder::CircuitBuilder, lv: &CpuColumnsView>, nv: &CpuColumnsView>, diff --git a/evm/src/cpu/jumps.rs b/evm/src/cpu/jumps.rs index b75ef494e8..2eb865e59e 100644 --- a/evm/src/cpu/jumps.rs +++ b/evm/src/cpu/jumps.rs @@ -10,7 +10,7 @@ use crate::cpu::membus::NUM_GP_CHANNELS; use crate::memory::segments::Segment; /// Evaluates constraints for EXIT_KERNEL. -pub fn eval_packed_exit_kernel( +pub(crate) fn eval_packed_exit_kernel( lv: &CpuColumnsView

, nv: &CpuColumnsView

, yield_constr: &mut ConstraintConsumer

, @@ -29,7 +29,7 @@ pub fn eval_packed_exit_kernel( /// Circuit version of `eval_packed_exit_kernel`. /// Evaluates constraints for EXIT_KERNEL. -pub fn eval_ext_circuit_exit_kernel, const D: usize>( +pub(crate) fn eval_ext_circuit_exit_kernel, const D: usize>( builder: &mut plonky2::plonk::circuit_builder::CircuitBuilder, lv: &CpuColumnsView>, nv: &CpuColumnsView>, @@ -63,7 +63,7 @@ pub fn eval_ext_circuit_exit_kernel, const D: usize } /// Evaluates constraints jump operations: JUMP and JUMPI. -pub fn eval_packed_jump_jumpi( +pub(crate) fn eval_packed_jump_jumpi( lv: &CpuColumnsView

, nv: &CpuColumnsView

, yield_constr: &mut ConstraintConsumer

, @@ -162,7 +162,7 @@ pub fn eval_packed_jump_jumpi( /// Circuit version of `eval_packed_jumpi_jumpi`. /// Evaluates constraints jump operations: JUMP and JUMPI. -pub fn eval_ext_circuit_jump_jumpi, const D: usize>( +pub(crate) fn eval_ext_circuit_jump_jumpi, const D: usize>( builder: &mut plonky2::plonk::circuit_builder::CircuitBuilder, lv: &CpuColumnsView>, nv: &CpuColumnsView>, @@ -360,7 +360,7 @@ pub fn eval_ext_circuit_jump_jumpi, const D: usize> } /// Evaluates constraints for EXIT_KERNEL, JUMP and JUMPI. -pub fn eval_packed( +pub(crate) fn eval_packed( lv: &CpuColumnsView

, nv: &CpuColumnsView

, yield_constr: &mut ConstraintConsumer

, @@ -371,7 +371,7 @@ pub fn eval_packed( /// Circuit version of `eval_packed`. /// Evaluates constraints for EXIT_KERNEL, JUMP and JUMPI. -pub fn eval_ext_circuit, const D: usize>( +pub(crate) fn eval_ext_circuit, const D: usize>( builder: &mut plonky2::plonk::circuit_builder::CircuitBuilder, lv: &CpuColumnsView>, nv: &CpuColumnsView>, diff --git a/evm/src/cpu/kernel/constants/journal_entry.rs b/evm/src/cpu/kernel/constants/journal_entry.rs index 8015ce2162..5fd8685197 100644 --- a/evm/src/cpu/kernel/constants/journal_entry.rs +++ b/evm/src/cpu/kernel/constants/journal_entry.rs @@ -1,4 +1,3 @@ -#[allow(dead_code)] #[derive(Copy, Clone, Eq, PartialEq, Hash, Ord, PartialOrd, Debug)] pub(crate) enum JournalEntry { AccountLoaded = 0, diff --git a/evm/src/cpu/kernel/constants/mod.rs b/evm/src/cpu/kernel/constants/mod.rs index 77abde994f..4c2df30888 100644 --- a/evm/src/cpu/kernel/constants/mod.rs +++ b/evm/src/cpu/kernel/constants/mod.rs @@ -18,7 +18,7 @@ pub(crate) mod trie_type; pub(crate) mod txn_fields; /// Constants that are accessible to our kernel assembly code. -pub fn evm_constants() -> HashMap { +pub(crate) fn evm_constants() -> HashMap { let mut c = HashMap::new(); let hex_constants = MISC_CONSTANTS diff --git a/evm/src/cpu/kernel/constants/txn_fields.rs b/evm/src/cpu/kernel/constants/txn_fields.rs index f4364c6f07..0eae47f090 100644 --- a/evm/src/cpu/kernel/constants/txn_fields.rs +++ b/evm/src/cpu/kernel/constants/txn_fields.rs @@ -1,5 +1,4 @@ /// These are normalized transaction fields, i.e. not specific to any transaction type. -#[allow(dead_code)] #[derive(Copy, Clone, Eq, PartialEq, Hash, Ord, PartialOrd, Debug)] pub(crate) enum NormalizedTxnField { /// Whether a chain ID was present in the txn data. Type 0 transaction with v=27 or v=28 have diff --git a/evm/src/cpu/kernel/interpreter.rs b/evm/src/cpu/kernel/interpreter.rs index 928c274827..b3c155df85 100644 --- a/evm/src/cpu/kernel/interpreter.rs +++ b/evm/src/cpu/kernel/interpreter.rs @@ -42,7 +42,7 @@ impl MemoryState { } } -pub struct Interpreter<'a> { +pub(crate) struct Interpreter<'a> { pub(crate) kernel_mode: bool, jumpdests: Vec, pub(crate) context: usize, @@ -54,7 +54,7 @@ pub struct Interpreter<'a> { opcode_count: [usize; 0x100], } -pub fn run_interpreter( +pub(crate) fn run_interpreter( initial_offset: usize, initial_stack: Vec, ) -> anyhow::Result> { @@ -67,14 +67,14 @@ pub fn run_interpreter( } #[derive(Clone)] -pub struct InterpreterMemoryInitialization { +pub(crate) struct InterpreterMemoryInitialization { pub label: String, pub stack: Vec, pub segment: Segment, pub memory: Vec<(usize, Vec)>, } -pub fn run_interpreter_with_memory( +pub(crate) fn run_interpreter_with_memory( memory_init: InterpreterMemoryInitialization, ) -> anyhow::Result> { let label = KERNEL.global_labels[&memory_init.label]; @@ -93,7 +93,7 @@ pub fn run_interpreter_with_memory( Ok(interpreter) } -pub fn run<'a>( +pub(crate) fn run<'a>( code: &'a [u8], initial_offset: usize, initial_stack: Vec, @@ -293,7 +293,7 @@ impl<'a> Interpreter<'a> { .content } - pub fn extract_kernel_memory(self, segment: Segment, range: Range) -> Vec { + pub(crate) fn extract_kernel_memory(self, segment: Segment, range: Range) -> Vec { let mut output: Vec = vec![]; for i in range { let term = self diff --git a/evm/src/cpu/kernel/parser.rs b/evm/src/cpu/kernel/parser.rs index 49181b716f..a17439e267 100644 --- a/evm/src/cpu/kernel/parser.rs +++ b/evm/src/cpu/kernel/parser.rs @@ -10,7 +10,7 @@ use crate::cpu::kernel::ast::{File, Item, PushTarget, StackReplacement}; /// Parses EVM assembly code. #[derive(pest_derive::Parser)] #[grammar = "cpu/kernel/evm_asm.pest"] -pub struct AsmParser; +struct AsmParser; pub(crate) fn parse(s: &str) -> File { let file = AsmParser::parse(Rule::file, s) diff --git a/evm/src/cpu/kernel/stack/permutations.rs b/evm/src/cpu/kernel/stack/permutations.rs index d64755ede6..50be605d3a 100644 --- a/evm/src/cpu/kernel/stack/permutations.rs +++ b/evm/src/cpu/kernel/stack/permutations.rs @@ -58,7 +58,7 @@ fn apply_perm(permutation: Vec>, mut lst: Vec(lst_a: &[T], lst_b: &[T]) -> Vec> { +pub(crate) fn find_permutation(lst_a: &[T], lst_b: &[T]) -> Vec> { // We should check to ensure that A and B are indeed rearrangments of each other. assert!(is_permutation(lst_a, lst_b)); @@ -210,7 +210,7 @@ fn transpositions_to_stack_ops(trans: Vec) -> Vec { trans.into_iter().map(|i| StackOp::Swap(i as u8)).collect() } -pub fn is_permutation(a: &[T], b: &[T]) -> bool { +pub(crate) fn is_permutation(a: &[T], b: &[T]) -> bool { make_multiset(a) == make_multiset(b) } diff --git a/evm/src/cpu/kernel/tests/receipt.rs b/evm/src/cpu/kernel/tests/receipt.rs index f82bbcda43..605ad9c0e4 100644 --- a/evm/src/cpu/kernel/tests/receipt.rs +++ b/evm/src/cpu/kernel/tests/receipt.rs @@ -588,7 +588,7 @@ fn test_bloom_two_logs() -> Result<()> { Ok(()) } -pub fn logs_bloom_bytes_fn(logs_list: Vec<(Vec, Vec>)>) -> [u8; 256] { +fn logs_bloom_bytes_fn(logs_list: Vec<(Vec, Vec>)>) -> [u8; 256] { // The first element of logs_list. let mut bloom = [0_u8; 256]; diff --git a/evm/src/cpu/membus.rs b/evm/src/cpu/membus.rs index fe967a2e3e..9fba0065a2 100644 --- a/evm/src/cpu/membus.rs +++ b/evm/src/cpu/membus.rs @@ -33,7 +33,7 @@ pub mod channel_indices { pub const NUM_CHANNELS: usize = channel_indices::GP.end; /// Evaluates constraints regarding the membus. -pub fn eval_packed( +pub(crate) fn eval_packed( lv: &CpuColumnsView

, yield_constr: &mut ConstraintConsumer

, ) { @@ -51,7 +51,7 @@ pub fn eval_packed( /// Circuit version of `eval_packed`. /// Evaluates constraints regarding the membus. -pub fn eval_ext_circuit, const D: usize>( +pub(crate) fn eval_ext_circuit, const D: usize>( builder: &mut plonky2::plonk::circuit_builder::CircuitBuilder, lv: &CpuColumnsView>, yield_constr: &mut RecursiveConstraintConsumer, diff --git a/evm/src/cpu/memio.rs b/evm/src/cpu/memio.rs index 71960f5ffc..065c0561a4 100644 --- a/evm/src/cpu/memio.rs +++ b/evm/src/cpu/memio.rs @@ -327,7 +327,7 @@ fn eval_ext_circuit_store, const D: usize>( } /// Evaluates constraints for MLOAD_GENERAL and MSTORE_GENERAL. -pub fn eval_packed( +pub(crate) fn eval_packed( lv: &CpuColumnsView

, nv: &CpuColumnsView

, yield_constr: &mut ConstraintConsumer

, @@ -338,7 +338,7 @@ pub fn eval_packed( /// Circuit version of `eval_packed`. /// Evaluates constraints for MLOAD_GENERAL and MSTORE_GENERAL. -pub fn eval_ext_circuit, const D: usize>( +pub(crate) fn eval_ext_circuit, const D: usize>( builder: &mut plonky2::plonk::circuit_builder::CircuitBuilder, lv: &CpuColumnsView>, nv: &CpuColumnsView>, diff --git a/evm/src/cpu/modfp254.rs b/evm/src/cpu/modfp254.rs index 82d270c9e6..95bab8d655 100644 --- a/evm/src/cpu/modfp254.rs +++ b/evm/src/cpu/modfp254.rs @@ -16,7 +16,7 @@ const P_LIMBS: [u32; 8] = [ ]; /// Evaluates constraints to check the modulus in mem_channel[2]. -pub fn eval_packed( +pub(crate) fn eval_packed( lv: &CpuColumnsView

, yield_constr: &mut ConstraintConsumer

, ) { @@ -34,7 +34,7 @@ pub fn eval_packed( /// Circuit version of `eval_packed`. /// Evaluates constraints to check the modulus in mem_channel[2]. -pub fn eval_ext_circuit, const D: usize>( +pub(crate) fn eval_ext_circuit, const D: usize>( builder: &mut plonky2::plonk::circuit_builder::CircuitBuilder, lv: &CpuColumnsView>, yield_constr: &mut RecursiveConstraintConsumer, diff --git a/evm/src/cpu/pc.rs b/evm/src/cpu/pc.rs index 16915a53e7..9635534e50 100644 --- a/evm/src/cpu/pc.rs +++ b/evm/src/cpu/pc.rs @@ -7,7 +7,7 @@ use crate::constraint_consumer::{ConstraintConsumer, RecursiveConstraintConsumer use crate::cpu::columns::CpuColumnsView; /// Evaluates constraints to check that we are storing the correct PC. -pub fn eval_packed( +pub(crate) fn eval_packed( lv: &CpuColumnsView

, nv: &CpuColumnsView

, yield_constr: &mut ConstraintConsumer

, @@ -23,7 +23,7 @@ pub fn eval_packed( /// Circuit version if `eval_packed`. /// Evaluates constraints to check that we are storing the correct PC. -pub fn eval_ext_circuit, const D: usize>( +pub(crate) fn eval_ext_circuit, const D: usize>( builder: &mut plonky2::plonk::circuit_builder::CircuitBuilder, lv: &CpuColumnsView>, nv: &CpuColumnsView>, diff --git a/evm/src/cpu/push0.rs b/evm/src/cpu/push0.rs index e48e77f375..ed9f6c10f2 100644 --- a/evm/src/cpu/push0.rs +++ b/evm/src/cpu/push0.rs @@ -7,7 +7,7 @@ use crate::constraint_consumer::{ConstraintConsumer, RecursiveConstraintConsumer use crate::cpu::columns::CpuColumnsView; /// Evaluates constraints to check that we are not pushing anything. -pub fn eval_packed( +pub(crate) fn eval_packed( lv: &CpuColumnsView

, nv: &CpuColumnsView

, yield_constr: &mut ConstraintConsumer

, @@ -21,7 +21,7 @@ pub fn eval_packed( /// Circuit version of `eval_packed`. /// Evaluates constraints to check that we are not pushing anything. -pub fn eval_ext_circuit, const D: usize>( +pub(crate) fn eval_ext_circuit, const D: usize>( builder: &mut plonky2::plonk::circuit_builder::CircuitBuilder, lv: &CpuColumnsView>, nv: &CpuColumnsView>, diff --git a/evm/src/cpu/simple_logic/eq_iszero.rs b/evm/src/cpu/simple_logic/eq_iszero.rs index 7692bb9065..fd811ae7f7 100644 --- a/evm/src/cpu/simple_logic/eq_iszero.rs +++ b/evm/src/cpu/simple_logic/eq_iszero.rs @@ -24,7 +24,7 @@ fn limbs(x: U256) -> [u32; 8] { /// Then `diff @ x = num_unequal_limbs`, where `@` denotes the dot product. We set /// `diff_pinv = num_unequal_limbs^-1 * x` if `num_unequal_limbs != 0` and 0 otherwise. We have /// `diff @ diff_pinv = 1 - equal` as desired. -pub fn generate_pinv_diff(val0: U256, val1: U256, lv: &mut CpuColumnsView) { +pub(crate) fn generate_pinv_diff(val0: U256, val1: U256, lv: &mut CpuColumnsView) { let val0_limbs = limbs(val0).map(F::from_canonical_u32); let val1_limbs = limbs(val1).map(F::from_canonical_u32); @@ -43,7 +43,7 @@ pub fn generate_pinv_diff(val0: U256, val1: U256, lv: &mut CpuColumnsV } /// Evaluates the constraints for EQ and ISZERO. -pub fn eval_packed( +pub(crate) fn eval_packed( lv: &CpuColumnsView

, nv: &CpuColumnsView

, yield_constr: &mut ConstraintConsumer

, @@ -101,7 +101,7 @@ pub fn eval_packed( /// Circuit version of `eval_packed`. /// Evaluates the constraints for EQ and ISZERO. -pub fn eval_ext_circuit, const D: usize>( +pub(crate) fn eval_ext_circuit, const D: usize>( builder: &mut plonky2::plonk::circuit_builder::CircuitBuilder, lv: &CpuColumnsView>, nv: &CpuColumnsView>, diff --git a/evm/src/cpu/simple_logic/mod.rs b/evm/src/cpu/simple_logic/mod.rs index dfe396fd48..04f8bcc2da 100644 --- a/evm/src/cpu/simple_logic/mod.rs +++ b/evm/src/cpu/simple_logic/mod.rs @@ -10,7 +10,7 @@ use crate::constraint_consumer::{ConstraintConsumer, RecursiveConstraintConsumer use crate::cpu::columns::CpuColumnsView; /// Evaluates constraints for NOT, EQ and ISZERO. -pub fn eval_packed( +pub(crate) fn eval_packed( lv: &CpuColumnsView

, nv: &CpuColumnsView

, yield_constr: &mut ConstraintConsumer

, @@ -21,7 +21,7 @@ pub fn eval_packed( /// Circuit version of `eval_packed`. /// Evaluates constraints for NOT, EQ and ISZERO. -pub fn eval_ext_circuit, const D: usize>( +pub(crate) fn eval_ext_circuit, const D: usize>( builder: &mut plonky2::plonk::circuit_builder::CircuitBuilder, lv: &CpuColumnsView>, nv: &CpuColumnsView>, diff --git a/evm/src/cpu/simple_logic/not.rs b/evm/src/cpu/simple_logic/not.rs index 727e840c8c..3798606de3 100644 --- a/evm/src/cpu/simple_logic/not.rs +++ b/evm/src/cpu/simple_logic/not.rs @@ -12,7 +12,7 @@ const LIMB_SIZE: usize = 32; const ALL_1_LIMB: u64 = (1 << LIMB_SIZE) - 1; /// Evaluates constraints for NOT. -pub fn eval_packed( +pub(crate) fn eval_packed( lv: &CpuColumnsView

, nv: &CpuColumnsView

, yield_constr: &mut ConstraintConsumer

, @@ -33,7 +33,7 @@ pub fn eval_packed( /// Circuit version of `eval_packed`. /// Evaluates constraints for NOT. -pub fn eval_ext_circuit, const D: usize>( +pub(crate) fn eval_ext_circuit, const D: usize>( builder: &mut plonky2::plonk::circuit_builder::CircuitBuilder, lv: &CpuColumnsView>, nv: &CpuColumnsView>, diff --git a/evm/src/cpu/stack.rs b/evm/src/cpu/stack.rs index dffdff42bb..60595184dd 100644 --- a/evm/src/cpu/stack.rs +++ b/evm/src/cpu/stack.rs @@ -257,7 +257,7 @@ pub(crate) fn eval_packed_one( } /// Evaluates constraints for all opcodes' `StackBehavior`s. -pub fn eval_packed( +pub(crate) fn eval_packed( lv: &CpuColumnsView

, nv: &CpuColumnsView

, yield_constr: &mut ConstraintConsumer

, @@ -535,7 +535,7 @@ pub(crate) fn eval_ext_circuit_one, const D: usize> /// Circuti version of `eval_packed`. /// Evaluates constraints for all opcodes' `StackBehavior`s. -pub fn eval_ext_circuit, const D: usize>( +pub(crate) fn eval_ext_circuit, const D: usize>( builder: &mut plonky2::plonk::circuit_builder::CircuitBuilder, lv: &CpuColumnsView>, nv: &CpuColumnsView>, diff --git a/evm/src/cpu/stack_bounds.rs b/evm/src/cpu/stack_bounds.rs index cc8c6aedfe..a99760e5c4 100644 --- a/evm/src/cpu/stack_bounds.rs +++ b/evm/src/cpu/stack_bounds.rs @@ -21,7 +21,7 @@ use crate::cpu::columns::CpuColumnsView; pub const MAX_USER_STACK_SIZE: usize = 1024; /// Evaluates constraints to check for stack overflows. -pub fn eval_packed( +pub(crate) fn eval_packed( lv: &CpuColumnsView

, yield_constr: &mut ConstraintConsumer

, ) { @@ -39,7 +39,7 @@ pub fn eval_packed( /// Circuit version of `eval_packed`. /// Evaluates constraints to check for stack overflows. -pub fn eval_ext_circuit, const D: usize>( +pub(crate) fn eval_ext_circuit, const D: usize>( builder: &mut plonky2::plonk::circuit_builder::CircuitBuilder, lv: &CpuColumnsView>, yield_constr: &mut RecursiveConstraintConsumer, diff --git a/evm/src/cpu/syscalls_exceptions.rs b/evm/src/cpu/syscalls_exceptions.rs index 78f1e0c1ae..49e28f7d21 100644 --- a/evm/src/cpu/syscalls_exceptions.rs +++ b/evm/src/cpu/syscalls_exceptions.rs @@ -20,7 +20,7 @@ const BYTES_PER_OFFSET: usize = crate::cpu::kernel::assembler::BYTES_PER_OFFSET const_assert!(BYTES_PER_OFFSET < NUM_GP_CHANNELS); // Reserve one channel for stack push /// Evaluates constraints for syscalls and exceptions. -pub fn eval_packed( +pub(crate) fn eval_packed( lv: &CpuColumnsView

, nv: &CpuColumnsView

, yield_constr: &mut ConstraintConsumer

, @@ -124,7 +124,7 @@ pub fn eval_packed( /// Circuit version of `eval_packed`. /// Evaluates constraints for syscalls and exceptions. -pub fn eval_ext_circuit, const D: usize>( +pub(crate) fn eval_ext_circuit, const D: usize>( builder: &mut plonky2::plonk::circuit_builder::CircuitBuilder, lv: &CpuColumnsView>, nv: &CpuColumnsView>, diff --git a/evm/src/cross_table_lookup.rs b/evm/src/cross_table_lookup.rs index d5d8b6b36b..6102b47547 100644 --- a/evm/src/cross_table_lookup.rs +++ b/evm/src/cross_table_lookup.rs @@ -60,7 +60,7 @@ use crate::stark::Stark; /// - a vector of `(usize, F)` corresponding to the column number and the associated multiplicand /// - the constant of the linear combination. #[derive(Clone, Debug)] -pub struct Column { +pub(crate) struct Column { linear_combination: Vec<(usize, F)>, next_row_linear_combination: Vec<(usize, F)>, constant: F, @@ -68,7 +68,7 @@ pub struct Column { impl Column { /// Returns the representation of a single column in the current row. - pub fn single(c: usize) -> Self { + pub(crate) fn single(c: usize) -> Self { Self { linear_combination: vec![(c, F::ONE)], next_row_linear_combination: vec![], @@ -77,14 +77,14 @@ impl Column { } /// Returns multiple single columns in the current row. - pub fn singles>>( + pub(crate) fn singles>>( cs: I, ) -> impl Iterator { cs.into_iter().map(|c| Self::single(*c.borrow())) } /// Returns the representation of a single column in the next row. - pub fn single_next_row(c: usize) -> Self { + pub(crate) fn single_next_row(c: usize) -> Self { Self { linear_combination: vec![], next_row_linear_combination: vec![(c, F::ONE)], @@ -93,14 +93,14 @@ impl Column { } /// Returns multiple single columns for the next row. - pub fn singles_next_row>>( + pub(crate) fn singles_next_row>>( cs: I, ) -> impl Iterator { cs.into_iter().map(|c| Self::single_next_row(*c.borrow())) } /// Returns a linear combination corresponding to a constant. - pub fn constant(constant: F) -> Self { + pub(crate) fn constant(constant: F) -> Self { Self { linear_combination: vec![], next_row_linear_combination: vec![], @@ -109,17 +109,17 @@ impl Column { } /// Returns a linear combination corresponding to 0. - pub fn zero() -> Self { + pub(crate) fn zero() -> Self { Self::constant(F::ZERO) } /// Returns a linear combination corresponding to 1. - pub fn one() -> Self { + pub(crate) fn one() -> Self { Self::constant(F::ONE) } /// Given an iterator of `(usize, F)` and a constant, returns the association linear combination of columns for the current row. - pub fn linear_combination_with_constant>( + pub(crate) fn linear_combination_with_constant>( iter: I, constant: F, ) -> Self { @@ -138,7 +138,9 @@ impl Column { } /// Given an iterator of `(usize, F)` and a constant, returns the associated linear combination of columns for the current and the next rows. - pub fn linear_combination_and_next_row_with_constant>( + pub(crate) fn linear_combination_and_next_row_with_constant< + I: IntoIterator, + >( iter: I, next_row_iter: I, constant: F, @@ -166,19 +168,19 @@ impl Column { } /// Returns a linear combination of columns, with no additional constant. - pub fn linear_combination>(iter: I) -> Self { + pub(crate) fn linear_combination>(iter: I) -> Self { Self::linear_combination_with_constant(iter, F::ZERO) } /// Given an iterator of columns (c_0, ..., c_n) containing bits in little endian order: /// returns the representation of c_0 + 2 * c_1 + ... + 2^n * c_n. - pub fn le_bits>>(cs: I) -> Self { + pub(crate) fn le_bits>>(cs: I) -> Self { Self::linear_combination(cs.into_iter().map(|c| *c.borrow()).zip(F::TWO.powers())) } /// Given an iterator of columns (c_0, ..., c_n) containing bytes in little endian order: /// returns the representation of c_0 + 256 * c_1 + ... + 256^n * c_n. - pub fn le_bytes>>(cs: I) -> Self { + pub(crate) fn le_bytes>>(cs: I) -> Self { Self::linear_combination( cs.into_iter() .map(|c| *c.borrow()) @@ -187,12 +189,12 @@ impl Column { } /// Given an iterator of columns, returns the representation of their sum. - pub fn sum>>(cs: I) -> Self { + pub(crate) fn sum>>(cs: I) -> Self { Self::linear_combination(cs.into_iter().map(|c| *c.borrow()).zip(repeat(F::ONE))) } /// Given the column values for the current row, returns the evaluation of the linear combination. - pub fn eval(&self, v: &[P]) -> P + pub(crate) fn eval(&self, v: &[P]) -> P where FE: FieldExtension, P: PackedField, @@ -205,7 +207,7 @@ impl Column { } /// Given the column values for the current and next rows, evaluates the current and next linear combinations and returns their sum. - pub fn eval_with_next(&self, v: &[P], next_v: &[P]) -> P + pub(crate) fn eval_with_next(&self, v: &[P], next_v: &[P]) -> P where FE: FieldExtension, P: PackedField, @@ -223,7 +225,7 @@ impl Column { } /// Evaluate on a row of a table given in column-major form. - pub fn eval_table(&self, table: &[PolynomialValues], row: usize) -> F { + pub(crate) fn eval_table(&self, table: &[PolynomialValues], row: usize) -> F { let mut res = self .linear_combination .iter() @@ -245,7 +247,7 @@ impl Column { } /// Circuit version of `eval`: Given a row's targets, returns their linear combination. - pub fn eval_circuit( + pub(crate) fn eval_circuit( &self, builder: &mut CircuitBuilder, v: &[ExtensionTarget], @@ -269,7 +271,7 @@ impl Column { /// Circuit version of `eval_with_next`: /// Given the targets of the current and next row, returns the sum of their linear combinations. - pub fn eval_with_next_circuit( + pub(crate) fn eval_with_next_circuit( &self, builder: &mut CircuitBuilder, v: &[ExtensionTarget], @@ -304,7 +306,7 @@ impl Column { /// `filter_column` is used to determine the rows to select in `Table`. /// `columns` represents linear combinations of the columns of `Table`. #[derive(Clone, Debug)] -pub struct TableWithColumns { +pub(crate) struct TableWithColumns { table: Table, columns: Vec>, pub(crate) filter_column: Option>, @@ -312,7 +314,11 @@ pub struct TableWithColumns { impl TableWithColumns { /// Generates a new `TableWithColumns` given a `Table`, a linear combination of columns `columns` and a `filter_column`. - pub fn new(table: Table, columns: Vec>, filter_column: Option>) -> Self { + pub(crate) fn new( + table: Table, + columns: Vec>, + filter_column: Option>, + ) -> Self { Self { table, columns, @@ -324,7 +330,7 @@ impl TableWithColumns { /// Cross-table lookup data consisting in the lookup table (`looked_table`) and all the tables that look into `looked_table` (`looking_tables`). /// Each `looking_table` corresponds to a STARK's table whose rows have been filtered out and whose columns have been through a linear combination (see `eval_table`). The concatenation of those smaller tables should result in the `looked_table`. #[derive(Clone)] -pub struct CrossTableLookup { +pub(crate) struct CrossTableLookup { /// Column linear combinations for all tables that are looking into the current table. pub(crate) looking_tables: Vec>, /// Column linear combination for the current table. @@ -334,7 +340,7 @@ pub struct CrossTableLookup { impl CrossTableLookup { /// Creates a new `CrossTableLookup` given some looking tables and a looked table. /// All tables should have the same width. - pub fn new( + pub(crate) fn new( looking_tables: Vec>, looked_table: TableWithColumns, ) -> Self { @@ -361,7 +367,7 @@ impl CrossTableLookup { /// Cross-table lookup data for one table. #[derive(Clone, Default)] -pub struct CtlData { +pub(crate) struct CtlData { /// Data associated with all Z(x) polynomials for one table. pub(crate) zs_columns: Vec>, } @@ -381,17 +387,17 @@ pub(crate) struct CtlZData { impl CtlData { /// Returns the number of cross-table lookup polynomials. - pub fn len(&self) -> usize { + pub(crate) fn len(&self) -> usize { self.zs_columns.len() } /// Returns whether there are no cross-table lookups. - pub fn is_empty(&self) -> bool { + pub(crate) fn is_empty(&self) -> bool { self.zs_columns.is_empty() } /// Returns all the cross-table lookup polynomials. - pub fn z_polys(&self) -> Vec> { + pub(crate) fn z_polys(&self) -> Vec> { self.zs_columns .iter() .map(|zs_columns| zs_columns.z.clone()) @@ -452,7 +458,7 @@ pub(crate) struct GrandProductChallengeSet { } impl GrandProductChallengeSet { - pub fn to_buffer(&self, buffer: &mut Vec) -> IoResult<()> { + pub(crate) fn to_buffer(&self, buffer: &mut Vec) -> IoResult<()> { buffer.write_usize(self.challenges.len())?; for challenge in &self.challenges { buffer.write_target(challenge.beta)?; @@ -461,7 +467,7 @@ impl GrandProductChallengeSet { Ok(()) } - pub fn from_buffer(buffer: &mut Buffer) -> IoResult { + pub(crate) fn from_buffer(buffer: &mut Buffer) -> IoResult { let length = buffer.read_usize()?; let mut challenges = Vec::with_capacity(length); for _ in 0..length { @@ -616,7 +622,7 @@ fn partial_products( /// Data necessary to check the cross-table lookups of a given table. #[derive(Clone)] -pub struct CtlCheckVars<'a, F, FE, P, const D2: usize> +pub(crate) struct CtlCheckVars<'a, F, FE, P, const D2: usize> where F: Field, FE: FieldExtension, @@ -741,7 +747,7 @@ pub(crate) fn eval_cross_table_lookup_checks { +pub(crate) struct CtlCheckVarsTarget<'a, F: Field, const D: usize> { /// Evaluation of the trace polynomials at point `zeta`. pub(crate) local_z: ExtensionTarget, /// Evaluation of the trace polynomials at point `g * zeta`. diff --git a/evm/src/curve_pairings.rs b/evm/src/curve_pairings.rs index a9b6f14abc..eca880b26a 100644 --- a/evm/src/curve_pairings.rs +++ b/evm/src/curve_pairings.rs @@ -8,7 +8,7 @@ use rand::Rng; use crate::extension_tower::{FieldExt, Fp12, Fp2, Fp6, Stack, BN254}; #[derive(Debug, Copy, Clone, PartialEq)] -pub struct Curve +pub(crate) struct Curve where T: FieldExt, { @@ -17,7 +17,7 @@ where } impl Curve { - pub fn unit() -> Self { + pub(crate) fn unit() -> Self { Curve { x: T::ZERO, y: T::ZERO, @@ -47,7 +47,7 @@ where T: FieldExt, Curve: CyclicGroup, { - pub fn int(z: i32) -> Self { + pub(crate) fn int(z: i32) -> Self { Curve::::GENERATOR * z } } @@ -195,7 +195,7 @@ impl CyclicGroup for Curve> { } // The tate pairing takes a point each from the curve and its twist and outputs an Fp12 element -pub fn bn_tate(p: Curve, q: Curve>) -> Fp12 { +pub(crate) fn bn_tate(p: Curve, q: Curve>) -> Fp12 { let miller_output = bn_miller_loop(p, q); bn_final_exponent(miller_output) } @@ -203,7 +203,7 @@ pub fn bn_tate(p: Curve, q: Curve>) -> Fp12 { /// Standard code for miller loop, can be found on page 99 at this url: /// https://static1.squarespace.com/static/5fdbb09f31d71c1227082339/t/5ff394720493bd28278889c6/1609798774687/PairingsForBeginners.pdf#page=107 /// where BN_EXP is a hardcoding of the array of Booleans that the loop traverses -pub fn bn_miller_loop(p: Curve, q: Curve>) -> Fp12 { +pub(crate) fn bn_miller_loop(p: Curve, q: Curve>) -> Fp12 { let mut r = p; let mut acc: Fp12 = Fp12::::UNIT; let mut line: Fp12; @@ -222,14 +222,14 @@ pub fn bn_miller_loop(p: Curve, q: Curve>) -> Fp12 { } /// The sloped line function for doubling a point -pub fn bn_tangent(p: Curve, q: Curve>) -> Fp12 { +pub(crate) fn bn_tangent(p: Curve, q: Curve>) -> Fp12 { let cx = -BN254::new(3) * p.x * p.x; let cy = BN254::new(2) * p.y; bn_sparse_embed(p.y * p.y - BN254::new(9), q.x * cx, q.y * cy) } /// The sloped line function for adding two points -pub fn bn_cord(p1: Curve, p2: Curve, q: Curve>) -> Fp12 { +pub(crate) fn bn_cord(p1: Curve, p2: Curve, q: Curve>) -> Fp12 { let cx = p2.y - p1.y; let cy = p1.x - p2.x; bn_sparse_embed(p1.y * p2.x - p2.y * p1.x, q.x * cx, q.y * cy) @@ -237,7 +237,7 @@ pub fn bn_cord(p1: Curve, p2: Curve, q: Curve>) -> Fp12 /// The tangent and cord functions output sparse Fp12 elements. /// This map embeds the nonzero coefficients into an Fp12. -pub fn bn_sparse_embed(g000: BN254, g01: Fp2, g11: Fp2) -> Fp12 { +pub(crate) fn bn_sparse_embed(g000: BN254, g01: Fp2, g11: Fp2) -> Fp12 { let g0 = Fp6 { t0: Fp2 { re: g000, @@ -256,7 +256,7 @@ pub fn bn_sparse_embed(g000: BN254, g01: Fp2, g11: Fp2) -> Fp12(rng: &mut R) -> Fp12 { +pub(crate) fn gen_bn_fp12_sparse(rng: &mut R) -> Fp12 { bn_sparse_embed( rng.gen::(), rng.gen::>(), @@ -276,7 +276,7 @@ pub fn gen_bn_fp12_sparse(rng: &mut R) -> Fp12 { /// (p^4 - p^2 + 1)/N = p^3 + (a2)p^2 - (a1)p - a0 /// where 0 < a0, a1, a2 < p. Then the final power is given by /// y = y_3 * (y^a2)_2 * (y^-a1)_1 * (y^-a0) -pub fn bn_final_exponent(f: Fp12) -> Fp12 { +pub(crate) fn bn_final_exponent(f: Fp12) -> Fp12 { let mut y = f.frob(6) / f; y = y.frob(2) * y; let (y_a2, y_a1, y_a0) = get_bn_custom_powers(y); diff --git a/evm/src/extension_tower.rs b/evm/src/extension_tower.rs index 845d99aa63..8faa0e8d03 100644 --- a/evm/src/extension_tower.rs +++ b/evm/src/extension_tower.rs @@ -29,7 +29,7 @@ pub const BN_BASE: U256 = U256([ ]); #[derive(Debug, Copy, Clone, PartialEq)] -pub struct BN254 { +pub(crate) struct BN254 { pub val: U256, } @@ -126,16 +126,16 @@ pub const BLS_BASE: U512 = U512([ ]); #[derive(Debug, Copy, Clone, PartialEq)] -pub struct BLS381 { +pub(crate) struct BLS381 { pub val: U512, } impl BLS381 { - pub fn lo(self) -> U256 { + pub(crate) fn lo(self) -> U256 { U256(self.val.0[..4].try_into().unwrap()) } - pub fn hi(self) -> U256 { + pub(crate) fn hi(self) -> U256 { U256(self.val.0[4..].try_into().unwrap()) } } @@ -260,7 +260,7 @@ impl Div for BLS381 { /// The degree 2 field extension Fp2 is given by adjoining i, the square root of -1, to BN254 /// The arithmetic in this extension is standard complex arithmetic #[derive(Debug, Copy, Clone, PartialEq)] -pub struct Fp2 +pub(crate) struct Fp2 where T: FieldExt, { @@ -812,7 +812,7 @@ impl Adj for Fp2 { /// The degree 3 field extension Fp6 over Fp2 is given by adjoining t, where t^3 = 1 + i /// Fp6 has basis 1, t, t^2 over Fp2 #[derive(Debug, Copy, Clone, PartialEq)] -pub struct Fp6 +pub(crate) struct Fp6 where T: FieldExt, Fp2: Adj, @@ -944,7 +944,7 @@ where /// while the values of /// t^(p^n) and t^(2p^n) /// are precomputed in the constant arrays FROB_T1 and FROB_T2 - pub fn frob(self, n: usize) -> Fp6 { + pub(crate) fn frob(self, n: usize) -> Fp6 { let n = n % 6; let frob_t1 = Fp2::::FROB_T[0][n]; let frob_t2 = Fp2::::FROB_T[1][n]; @@ -1031,7 +1031,7 @@ where /// The degree 2 field extension Fp12 over Fp6 is given by /// adjoining z, where z^2 = t. It thus has basis 1, z over Fp6 #[derive(Debug, Copy, Clone, PartialEq)] -pub struct Fp12 +pub(crate) struct Fp12 where T: FieldExt, Fp2: Adj, @@ -1200,7 +1200,7 @@ where /// which sends a + bz: Fp12 to /// a^(p^n) + b^(p^n) * z^(p^n) /// where the values of z^(p^n) are precomputed in the constant array FROB_Z - pub fn frob(self, n: usize) -> Fp12 { + pub(crate) fn frob(self, n: usize) -> Fp12 { let n = n % 12; Fp12 { z0: self.z0.frob(n), diff --git a/evm/src/fixed_recursive_verifier.rs b/evm/src/fixed_recursive_verifier.rs index 42919a97eb..854e05179f 100644 --- a/evm/src/fixed_recursive_verifier.rs +++ b/evm/src/fixed_recursive_verifier.rs @@ -96,7 +96,7 @@ where F: RichField + Extendable, C: GenericConfig, { - pub fn to_buffer( + fn to_buffer( &self, buffer: &mut Vec, gate_serializer: &dyn GateSerializer, @@ -114,7 +114,7 @@ where Ok(()) } - pub fn from_buffer( + fn from_buffer( buffer: &mut Buffer, gate_serializer: &dyn GateSerializer, generator_serializer: &dyn WitnessGeneratorSerializer, @@ -161,7 +161,7 @@ where F: RichField + Extendable, C: GenericConfig, { - pub fn to_buffer( + fn to_buffer( &self, buffer: &mut Vec, gate_serializer: &dyn GateSerializer, @@ -175,7 +175,7 @@ where Ok(()) } - pub fn from_buffer( + fn from_buffer( buffer: &mut Buffer, gate_serializer: &dyn GateSerializer, generator_serializer: &dyn WitnessGeneratorSerializer, @@ -196,21 +196,21 @@ where } #[derive(Eq, PartialEq, Debug)] -pub struct AggregationChildTarget { +struct AggregationChildTarget { is_agg: BoolTarget, agg_proof: ProofWithPublicInputsTarget, evm_proof: ProofWithPublicInputsTarget, } impl AggregationChildTarget { - pub fn to_buffer(&self, buffer: &mut Vec) -> IoResult<()> { + fn to_buffer(&self, buffer: &mut Vec) -> IoResult<()> { buffer.write_target_bool(self.is_agg)?; buffer.write_target_proof_with_public_inputs(&self.agg_proof)?; buffer.write_target_proof_with_public_inputs(&self.evm_proof)?; Ok(()) } - pub fn from_buffer(buffer: &mut Buffer) -> IoResult { + fn from_buffer(buffer: &mut Buffer) -> IoResult { let is_agg = buffer.read_target_bool()?; let agg_proof = buffer.read_target_proof_with_public_inputs()?; let evm_proof = buffer.read_target_proof_with_public_inputs()?; @@ -221,7 +221,7 @@ impl AggregationChildTarget { }) } - pub fn public_values>( + fn public_values>( &self, builder: &mut CircuitBuilder, ) -> PublicValuesTarget { @@ -250,7 +250,7 @@ where F: RichField + Extendable, C: GenericConfig, { - pub fn to_buffer( + fn to_buffer( &self, buffer: &mut Vec, gate_serializer: &dyn GateSerializer, @@ -265,7 +265,7 @@ where Ok(()) } - pub fn from_buffer( + fn from_buffer( buffer: &mut Buffer, gate_serializer: &dyn GateSerializer, generator_serializer: &dyn WitnessGeneratorSerializer, @@ -760,7 +760,7 @@ where } /// Connect the 256 block hashes between two blocks - pub fn connect_block_hashes( + fn connect_block_hashes( builder: &mut CircuitBuilder, lhs: &ProofWithPublicInputsTarget, rhs: &ProofWithPublicInputsTarget, @@ -1103,7 +1103,7 @@ where C: GenericConfig, C::Hasher: AlgebraicHasher, { - pub fn to_buffer( + fn to_buffer( &self, buffer: &mut Vec, gate_serializer: &dyn GateSerializer, @@ -1117,7 +1117,7 @@ where Ok(()) } - pub fn from_buffer( + fn from_buffer( buffer: &mut Buffer, gate_serializer: &dyn GateSerializer, generator_serializer: &dyn WitnessGeneratorSerializer, @@ -1195,7 +1195,7 @@ where C: GenericConfig, C::Hasher: AlgebraicHasher, { - pub fn to_buffer( + fn to_buffer( &self, buffer: &mut Vec, gate_serializer: &dyn GateSerializer, @@ -1222,7 +1222,7 @@ where Ok(()) } - pub fn from_buffer( + fn from_buffer( buffer: &mut Buffer, gate_serializer: &dyn GateSerializer, generator_serializer: &dyn WitnessGeneratorSerializer, diff --git a/evm/src/generation/state.rs b/evm/src/generation/state.rs index 506738ba72..938e83b8b1 100644 --- a/evm/src/generation/state.rs +++ b/evm/src/generation/state.rs @@ -82,7 +82,7 @@ impl GenerationState { /// Updates `program_counter`, and potentially adds some extra handling if we're jumping to a /// special location. - pub fn jump_to(&mut self, dst: usize) -> Result<(), ProgramError> { + pub(crate) fn jump_to(&mut self, dst: usize) -> Result<(), ProgramError> { self.registers.program_counter = dst; if dst == KERNEL.global_labels["observe_new_address"] { let tip_u256 = stack_peek(self, 0)?; @@ -100,14 +100,14 @@ impl GenerationState { /// Observe the given address, so that we will be able to recognize the associated state key. /// This is just for debugging purposes. - pub fn observe_address(&mut self, address: Address) { + pub(crate) fn observe_address(&mut self, address: Address) { let state_key = keccak(address.0); self.state_key_to_address.insert(state_key, address); } /// Observe the given code hash and store the associated code. /// When called, the code corresponding to `codehash` should be stored in the return data. - pub fn observe_contract(&mut self, codehash: H256) -> Result<(), ProgramError> { + pub(crate) fn observe_contract(&mut self, codehash: H256) -> Result<(), ProgramError> { if self.inputs.contract_code.contains_key(&codehash) { return Ok(()); // Return early if the code hash has already been observed. } @@ -131,14 +131,14 @@ impl GenerationState { Ok(()) } - pub fn checkpoint(&self) -> GenerationStateCheckpoint { + pub(crate) fn checkpoint(&self) -> GenerationStateCheckpoint { GenerationStateCheckpoint { registers: self.registers, traces: self.traces.checkpoint(), } } - pub fn rollback(&mut self, checkpoint: GenerationStateCheckpoint) { + pub(crate) fn rollback(&mut self, checkpoint: GenerationStateCheckpoint) { self.registers = checkpoint.registers; self.traces.rollback(checkpoint.traces); } diff --git a/evm/src/keccak/columns.rs b/evm/src/keccak/columns.rs index d9a71af4ff..cd801ebc08 100644 --- a/evm/src/keccak/columns.rs +++ b/evm/src/keccak/columns.rs @@ -12,7 +12,7 @@ pub const fn reg_step(i: usize) -> usize { /// Registers to hold permutation inputs. /// `reg_input_limb(2*i) -> input[i] as u32` /// `reg_input_limb(2*i+1) -> input[i] >> 32` -pub fn reg_input_limb(i: usize) -> Column { +pub(crate) fn reg_input_limb(i: usize) -> Column { debug_assert!(i < 2 * NUM_INPUTS); let i_u64 = i / 2; // The index of the 64-bit chunk. diff --git a/evm/src/keccak/keccak_stark.rs b/evm/src/keccak/keccak_stark.rs index 19524e2d8b..9870b90643 100644 --- a/evm/src/keccak/keccak_stark.rs +++ b/evm/src/keccak/keccak_stark.rs @@ -34,31 +34,31 @@ pub(crate) const NUM_ROUNDS: usize = 24; pub(crate) const NUM_INPUTS: usize = 25; /// Create vector of `Columns` corresponding to the permutation input limbs. -pub fn ctl_data_inputs() -> Vec> { +pub(crate) fn ctl_data_inputs() -> Vec> { let mut res: Vec<_> = (0..2 * NUM_INPUTS).map(reg_input_limb).collect(); res.push(Column::single(TIMESTAMP)); res } /// Create vector of `Columns` corresponding to the permutation output limbs. -pub fn ctl_data_outputs() -> Vec> { +pub(crate) fn ctl_data_outputs() -> Vec> { let mut res: Vec<_> = Column::singles((0..2 * NUM_INPUTS).map(reg_output_limb)).collect(); res.push(Column::single(TIMESTAMP)); res } /// CTL filter for the first round of the Keccak permutation. -pub fn ctl_filter_inputs() -> Column { +pub(crate) fn ctl_filter_inputs() -> Column { Column::single(reg_step(0)) } /// CTL filter for the final round of the Keccak permutation. -pub fn ctl_filter_outputs() -> Column { +pub(crate) fn ctl_filter_outputs() -> Column { Column::single(reg_step(NUM_ROUNDS - 1)) } #[derive(Copy, Clone, Default)] -pub struct KeccakStark { +pub(crate) struct KeccakStark { pub(crate) f: PhantomData, } @@ -231,7 +231,7 @@ impl, const D: usize> KeccakStark { row[out_reg_hi] = F::from_canonical_u64(row[in_reg_hi].to_canonical_u64() ^ rc_hi); } - pub fn generate_trace( + pub(crate) fn generate_trace( &self, inputs: Vec<([u64; NUM_INPUTS], usize)>, min_rows: usize, diff --git a/evm/src/keccak_sponge/keccak_sponge_stark.rs b/evm/src/keccak_sponge/keccak_sponge_stark.rs index 30db80838a..a89be91c6b 100644 --- a/evm/src/keccak_sponge/keccak_sponge_stark.rs +++ b/evm/src/keccak_sponge/keccak_sponge_stark.rs @@ -231,7 +231,7 @@ pub(crate) struct KeccakSpongeOp { /// Structure representing the `KeccakSponge` STARK, which carries out the sponge permutation. #[derive(Copy, Clone, Default)] -pub struct KeccakSpongeStark { +pub(crate) struct KeccakSpongeStark { f: PhantomData, } diff --git a/evm/src/lib.rs b/evm/src/lib.rs index b678ec58e4..f3bd0989f1 100644 --- a/evm/src/lib.rs +++ b/evm/src/lib.rs @@ -3,6 +3,7 @@ #![allow(clippy::too_many_arguments)] #![allow(clippy::type_complexity)] #![allow(clippy::field_reassign_with_default)] +#![allow(unused)] #![feature(let_chains)] pub mod all_stark; @@ -27,12 +28,14 @@ pub mod proof; pub mod prover; pub mod recursive_verifier; pub mod stark; -pub mod stark_testing; pub mod util; pub mod vanishing_poly; pub mod verifier; pub mod witness; +#[cfg(test)] +mod stark_testing; + use eth_trie_utils::partial_trie::HashedPartialTrie; // Set up Jemalloc #[cfg(not(target_env = "msvc"))] diff --git a/evm/src/logic.rs b/evm/src/logic.rs index 2382897b1a..c45a9f4bf1 100644 --- a/evm/src/logic.rs +++ b/evm/src/logic.rs @@ -47,7 +47,9 @@ pub(crate) mod columns { pub const RESULT: Range = INPUT1.end..INPUT1.end + PACKED_LEN; /// Returns the column range for each 32 bit chunk in the input. - pub fn limb_bit_cols_for_input(input_bits: Range) -> impl Iterator> { + pub(crate) fn limb_bit_cols_for_input( + input_bits: Range, + ) -> impl Iterator> { (0..PACKED_LEN).map(move |i| { let start = input_bits.start + i * PACKED_LIMB_BITS; let end = min(start + PACKED_LIMB_BITS, input_bits.end); @@ -60,7 +62,7 @@ pub(crate) mod columns { } /// Creates the vector of `Columns` corresponding to the opcode, the two inputs and the output of the logic operation. -pub fn ctl_data() -> Vec> { +pub(crate) fn ctl_data() -> Vec> { // We scale each filter flag with the associated opcode value. // If a logic operation is happening on the CPU side, the CTL // will enforce that the reconstructed opcode value from the @@ -77,13 +79,13 @@ pub fn ctl_data() -> Vec> { } /// CTL filter for logic operations. -pub fn ctl_filter() -> Column { +pub(crate) fn ctl_filter() -> Column { Column::sum([columns::IS_AND, columns::IS_OR, columns::IS_XOR]) } /// Structure representing the Logic STARK, which computes all logic operations. #[derive(Copy, Clone, Default)] -pub struct LogicStark { +pub(crate) struct LogicStark { pub f: PhantomData, } diff --git a/evm/src/lookup.rs b/evm/src/lookup.rs index a85544adc8..a93e4fb348 100644 --- a/evm/src/lookup.rs +++ b/evm/src/lookup.rs @@ -116,7 +116,7 @@ pub(crate) fn lookup_helper_columns( helper_columns } -pub struct LookupCheckVars +pub(crate) struct LookupCheckVars where F: Field, FE: FieldExtension, @@ -179,7 +179,7 @@ pub(crate) fn eval_packed_lookups_generic { +pub(crate) struct LookupCheckVarsTarget { pub(crate) local_values: Vec>, pub(crate) next_values: Vec>, pub(crate) challenges: Vec, diff --git a/evm/src/memory/memory_stark.rs b/evm/src/memory/memory_stark.rs index 725ae79d4c..689351e551 100644 --- a/evm/src/memory/memory_stark.rs +++ b/evm/src/memory/memory_stark.rs @@ -32,7 +32,7 @@ use crate::witness::memory::{MemoryAddress, MemoryOp}; /// - the address in memory of the element being read/written, /// - the value being read/written, /// - the timestamp at which the element is read/written. -pub fn ctl_data() -> Vec> { +pub(crate) fn ctl_data() -> Vec> { let mut res = Column::singles([IS_READ, ADDR_CONTEXT, ADDR_SEGMENT, ADDR_VIRTUAL]).collect_vec(); res.extend(Column::singles((0..8).map(value_limb))); @@ -41,12 +41,12 @@ pub fn ctl_data() -> Vec> { } /// CTL filter for memory operations. -pub fn ctl_filter() -> Column { +pub(crate) fn ctl_filter() -> Column { Column::single(FILTER) } #[derive(Copy, Clone, Default)] -pub struct MemoryStark { +pub(crate) struct MemoryStark { pub(crate) f: PhantomData, } @@ -76,7 +76,9 @@ impl MemoryOp { } /// Generates the `_FIRST_CHANGE` columns and the `RANGE_CHECK` column in the trace. -pub fn generate_first_change_flags_and_rc(trace_rows: &mut [[F; NUM_COLUMNS]]) { +pub(crate) fn generate_first_change_flags_and_rc( + trace_rows: &mut [[F; NUM_COLUMNS]], +) { let num_ops = trace_rows.len(); for idx in 0..num_ops - 1 { let row = trace_rows[idx].as_slice(); diff --git a/evm/src/memory/segments.rs b/evm/src/memory/segments.rs index afaaf503b0..855f7218ab 100644 --- a/evm/src/memory/segments.rs +++ b/evm/src/memory/segments.rs @@ -1,4 +1,3 @@ -#[allow(dead_code)] #[derive(Copy, Clone, Eq, PartialEq, Hash, Ord, PartialOrd, Debug)] pub enum Segment { /// Contains EVM bytecode. @@ -160,7 +159,6 @@ impl Segment { } } - #[allow(dead_code)] pub(crate) fn bit_range(&self) -> usize { match self { Segment::Code => 8, diff --git a/evm/src/proof.rs b/evm/src/proof.rs index c8760a6b2e..1cdaa66eb8 100644 --- a/evm/src/proof.rs +++ b/evm/src/proof.rs @@ -156,7 +156,7 @@ pub struct ExtraBlockData { /// Memory values which are public. /// Note: All the larger integers are encoded with 32-bit limbs in little-endian order. #[derive(Eq, PartialEq, Debug)] -pub struct PublicValuesTarget { +pub(crate) struct PublicValuesTarget { /// Trie hashes before the execution of the local state transition. pub trie_roots_before: TrieRootsTarget, /// Trie hashes after the execution of the local state transition. @@ -171,7 +171,7 @@ pub struct PublicValuesTarget { impl PublicValuesTarget { /// Serializes public value targets. - pub fn to_buffer(&self, buffer: &mut Vec) -> IoResult<()> { + pub(crate) fn to_buffer(&self, buffer: &mut Vec) -> IoResult<()> { let TrieRootsTarget { state_root: state_root_before, transactions_root: transactions_root_before, @@ -244,7 +244,7 @@ impl PublicValuesTarget { } /// Deserializes public value targets. - pub fn from_buffer(buffer: &mut Buffer) -> IoResult { + pub(crate) fn from_buffer(buffer: &mut Buffer) -> IoResult { let trie_roots_before = TrieRootsTarget { state_root: buffer.read_target_array()?, transactions_root: buffer.read_target_array()?, @@ -297,7 +297,7 @@ impl PublicValuesTarget { /// Extracts public value `Target`s from the given public input `Target`s. /// Public values are always the first public inputs added to the circuit, /// so we can start extracting at index 0. - pub fn from_public_inputs(pis: &[Target]) -> Self { + pub(crate) fn from_public_inputs(pis: &[Target]) -> Self { assert!( pis.len() > TrieRootsTarget::SIZE * 2 @@ -335,7 +335,7 @@ impl PublicValuesTarget { } /// Returns the public values in `pv0` or `pv1` depening on `condition`. - pub fn select, const D: usize>( + pub(crate) fn select, const D: usize>( builder: &mut CircuitBuilder, condition: BoolTarget, pv0: Self, @@ -379,13 +379,13 @@ impl PublicValuesTarget { /// Circuit version of `TrieRoots`. /// `Target`s for trie hashes. Since a `Target` holds a 32-bit limb, each hash requires 8 `Target`s. #[derive(Eq, PartialEq, Debug, Copy, Clone)] -pub struct TrieRootsTarget { +pub(crate) struct TrieRootsTarget { /// Targets for the state trie hash. - pub state_root: [Target; 8], + pub(crate) state_root: [Target; 8], /// Targets for the transactions trie hash. - pub transactions_root: [Target; 8], + pub(crate) transactions_root: [Target; 8], /// Targets for the receipts trie hash. - pub receipts_root: [Target; 8], + pub(crate) receipts_root: [Target; 8], } impl TrieRootsTarget { @@ -394,7 +394,7 @@ impl TrieRootsTarget { /// Extracts trie hash `Target`s for all tries from the provided public input `Target`s. /// The provided `pis` should start with the trie hashes. - pub fn from_public_inputs(pis: &[Target]) -> Self { + pub(crate) fn from_public_inputs(pis: &[Target]) -> Self { let state_root = pis[0..8].try_into().unwrap(); let transactions_root = pis[8..16].try_into().unwrap(); let receipts_root = pis[16..24].try_into().unwrap(); @@ -408,7 +408,7 @@ impl TrieRootsTarget { /// If `condition`, returns the trie hashes in `tr0`, /// otherwise returns the trie hashes in `tr1`. - pub fn select, const D: usize>( + pub(crate) fn select, const D: usize>( builder: &mut CircuitBuilder, condition: BoolTarget, tr0: Self, @@ -432,7 +432,7 @@ impl TrieRootsTarget { } /// Connects the trie hashes in `tr0` and in `tr1`. - pub fn connect, const D: usize>( + pub(crate) fn connect, const D: usize>( builder: &mut CircuitBuilder, tr0: Self, tr1: Self, @@ -449,27 +449,27 @@ impl TrieRootsTarget { /// Metadata contained in a block header. Those are identical between /// all state transition proofs within the same block. #[derive(Eq, PartialEq, Debug, Copy, Clone)] -pub struct BlockMetadataTarget { +pub(crate) struct BlockMetadataTarget { /// `Target`s for the address of this block's producer. - pub block_beneficiary: [Target; 5], + pub(crate) block_beneficiary: [Target; 5], /// `Target` for the timestamp of this block. - pub block_timestamp: Target, + pub(crate) block_timestamp: Target, /// `Target` for the index of this block. - pub block_number: Target, + pub(crate) block_number: Target, /// `Target` for the difficulty (before PoS transition) of this block. - pub block_difficulty: Target, + pub(crate) block_difficulty: Target, /// `Target`s for the `mix_hash` value of this block. - pub block_random: [Target; 8], + pub(crate) block_random: [Target; 8], /// `Target`s for the gas limit of this block. - pub block_gaslimit: [Target; 2], + pub(crate) block_gaslimit: [Target; 2], /// `Target` for the chain id of this block. - pub block_chain_id: Target, + pub(crate) block_chain_id: Target, /// `Target`s for the base fee of this block. - pub block_base_fee: [Target; 2], + pub(crate) block_base_fee: [Target; 2], /// `Target`s for the gas used of this block. - pub block_gas_used: [Target; 2], + pub(crate) block_gas_used: [Target; 2], /// `Target`s for the block bloom of this block. - pub block_bloom: [Target; 64], + pub(crate) block_bloom: [Target; 64], } impl BlockMetadataTarget { @@ -478,7 +478,7 @@ impl BlockMetadataTarget { /// Extracts block metadata `Target`s from the provided public input `Target`s. /// The provided `pis` should start with the block metadata. - pub fn from_public_inputs(pis: &[Target]) -> Self { + pub(crate) fn from_public_inputs(pis: &[Target]) -> Self { let block_beneficiary = pis[0..5].try_into().unwrap(); let block_timestamp = pis[5]; let block_number = pis[6]; @@ -506,7 +506,7 @@ impl BlockMetadataTarget { /// If `condition`, returns the block metadata in `bm0`, /// otherwise returns the block metadata in `bm1`. - pub fn select, const D: usize>( + pub(crate) fn select, const D: usize>( builder: &mut CircuitBuilder, condition: BoolTarget, bm0: Self, @@ -543,7 +543,7 @@ impl BlockMetadataTarget { } /// Connects the block metadata in `bm0` to the block metadata in `bm1`. - pub fn connect, const D: usize>( + pub(crate) fn connect, const D: usize>( builder: &mut CircuitBuilder, bm0: Self, bm1: Self, @@ -582,21 +582,21 @@ impl BlockMetadataTarget { /// When the block number is less than 256, dummy values, i.e. `H256::default()`, /// should be used for the additional block hashes. #[derive(Eq, PartialEq, Debug, Copy, Clone)] -pub struct BlockHashesTarget { +pub(crate) struct BlockHashesTarget { /// `Target`s for the previous 256 hashes to the current block. The leftmost hash, i.e. `prev_hashes[0..8]`, /// is the oldest, and the rightmost, i.e. `prev_hashes[255 * 7..255 * 8]` is the hash of the parent block. - pub prev_hashes: [Target; 2048], + pub(crate) prev_hashes: [Target; 2048], // `Target` for the hash of the current block. - pub cur_hash: [Target; 8], + pub(crate) cur_hash: [Target; 8], } impl BlockHashesTarget { /// Number of `Target`s required for previous and current block hashes. - pub const BLOCK_HASHES_SIZE: usize = 2056; + pub(crate) const BLOCK_HASHES_SIZE: usize = 2056; /// Extracts the previous and current block hash `Target`s from the public input `Target`s. /// The provided `pis` should start with the block hashes. - pub fn from_public_inputs(pis: &[Target]) -> Self { + pub(crate) fn from_public_inputs(pis: &[Target]) -> Self { Self { prev_hashes: pis[0..2048].try_into().unwrap(), cur_hash: pis[2048..2056].try_into().unwrap(), @@ -605,7 +605,7 @@ impl BlockHashesTarget { /// If `condition`, returns the block hashes in `bm0`, /// otherwise returns the block hashes in `bm1`. - pub fn select, const D: usize>( + pub(crate) fn select, const D: usize>( builder: &mut CircuitBuilder, condition: BoolTarget, bm0: Self, @@ -622,7 +622,7 @@ impl BlockHashesTarget { } /// Connects the block hashes in `bm0` to the block hashes in `bm1`. - pub fn connect, const D: usize>( + pub(crate) fn connect, const D: usize>( builder: &mut CircuitBuilder, bm0: Self, bm1: Self, @@ -640,7 +640,7 @@ impl BlockHashesTarget { /// Additional block data that are specific to the local transaction being proven, /// unlike `BlockMetadata`. #[derive(Eq, PartialEq, Debug, Copy, Clone)] -pub struct ExtraBlockDataTarget { +pub(crate) struct ExtraBlockDataTarget { /// `Target`s for the state trie digest of the genesis block. pub genesis_state_trie_root: [Target; 8], /// `Target` for the transaction count prior execution of the local state transition, starting @@ -668,7 +668,7 @@ impl ExtraBlockDataTarget { /// Extracts the extra block data `Target`s from the public input `Target`s. /// The provided `pis` should start with the extra vblock data. - pub fn from_public_inputs(pis: &[Target]) -> Self { + pub(crate) fn from_public_inputs(pis: &[Target]) -> Self { let genesis_state_trie_root = pis[0..8].try_into().unwrap(); let txn_number_before = pis[8]; let txn_number_after = pis[9]; @@ -690,7 +690,7 @@ impl ExtraBlockDataTarget { /// If `condition`, returns the extra block data in `ed0`, /// otherwise returns the extra block data in `ed1`. - pub fn select, const D: usize>( + pub(crate) fn select, const D: usize>( builder: &mut CircuitBuilder, condition: BoolTarget, ed0: Self, @@ -734,7 +734,7 @@ impl ExtraBlockDataTarget { } /// Connects the extra block data in `ed0` with the extra block data in `ed1`. - pub fn connect, const D: usize>( + pub(crate) fn connect, const D: usize>( builder: &mut CircuitBuilder, ed0: Self, ed1: Self, @@ -811,7 +811,7 @@ impl, C: GenericConfig, const D: usize> S /// Circuit version of `StarkProof`. /// Merkle caps and openings that form the proof of a single STARK. #[derive(Eq, PartialEq, Debug)] -pub struct StarkProofTarget { +pub(crate) struct StarkProofTarget { /// `Target` for the Merkle cap if LDEs of trace values. pub trace_cap: MerkleCapTarget, /// `Target` for the Merkle cap of LDEs of lookup helper and CTL columns. @@ -826,7 +826,7 @@ pub struct StarkProofTarget { impl StarkProofTarget { /// Serializes a STARK proof. - pub fn to_buffer(&self, buffer: &mut Vec) -> IoResult<()> { + pub(crate) fn to_buffer(&self, buffer: &mut Vec) -> IoResult<()> { buffer.write_target_merkle_cap(&self.trace_cap)?; buffer.write_target_merkle_cap(&self.auxiliary_polys_cap)?; buffer.write_target_merkle_cap(&self.quotient_polys_cap)?; @@ -836,7 +836,7 @@ impl StarkProofTarget { } /// Deserializes a STARK proof. - pub fn from_buffer(buffer: &mut Buffer) -> IoResult { + pub(crate) fn from_buffer(buffer: &mut Buffer) -> IoResult { let trace_cap = buffer.read_target_merkle_cap()?; let auxiliary_polys_cap = buffer.read_target_merkle_cap()?; let quotient_polys_cap = buffer.read_target_merkle_cap()?; @@ -853,7 +853,7 @@ impl StarkProofTarget { } /// Recover the length of the trace from a STARK proof and a STARK config. - pub fn recover_degree_bits(&self, config: &StarkConfig) -> usize { + pub(crate) fn recover_degree_bits(&self, config: &StarkConfig) -> usize { let initial_merkle_proof = &self.opening_proof.query_round_proofs[0] .initial_trees_proof .evals_proofs[0] @@ -981,7 +981,7 @@ impl, const D: usize> StarkOpeningSet { /// Circuit version of `StarkOpeningSet`. /// `Target`s for the purported values of each polynomial at the challenge point. #[derive(Eq, PartialEq, Debug)] -pub struct StarkOpeningSetTarget { +pub(crate) struct StarkOpeningSetTarget { /// `ExtensionTarget`s for the openings of trace polynomials at `zeta`. pub local_values: Vec>, /// `ExtensionTarget`s for the opening of trace polynomials at `g * zeta`. @@ -998,7 +998,7 @@ pub struct StarkOpeningSetTarget { impl StarkOpeningSetTarget { /// Serializes a STARK's opening set. - pub fn to_buffer(&self, buffer: &mut Vec) -> IoResult<()> { + pub(crate) fn to_buffer(&self, buffer: &mut Vec) -> IoResult<()> { buffer.write_target_ext_vec(&self.local_values)?; buffer.write_target_ext_vec(&self.next_values)?; buffer.write_target_ext_vec(&self.auxiliary_polys)?; @@ -1009,7 +1009,7 @@ impl StarkOpeningSetTarget { } /// Deserializes a STARK's opening set. - pub fn from_buffer(buffer: &mut Buffer) -> IoResult { + pub(crate) fn from_buffer(buffer: &mut Buffer) -> IoResult { let local_values = buffer.read_target_ext_vec::()?; let next_values = buffer.read_target_ext_vec::()?; let auxiliary_polys = buffer.read_target_ext_vec::()?; diff --git a/evm/src/recursive_verifier.rs b/evm/src/recursive_verifier.rs index 7464eb1715..792724a24f 100644 --- a/evm/src/recursive_verifier.rs +++ b/evm/src/recursive_verifier.rs @@ -110,7 +110,7 @@ where C: GenericConfig, C::Hasher: AlgebraicHasher, { - pub fn to_buffer( + pub(crate) fn to_buffer( &self, buffer: &mut Vec, gate_serializer: &dyn GateSerializer, @@ -124,7 +124,7 @@ where Ok(()) } - pub fn from_buffer( + pub(crate) fn from_buffer( buffer: &mut Buffer, gate_serializer: &dyn GateSerializer, generator_serializer: &dyn WitnessGeneratorSerializer, diff --git a/evm/src/stark_testing.rs b/evm/src/stark_testing.rs index 5fe44127f9..3568f00433 100644 --- a/evm/src/stark_testing.rs +++ b/evm/src/stark_testing.rs @@ -18,7 +18,11 @@ const WITNESS_SIZE: usize = 1 << 5; /// Tests that the constraints imposed by the given STARK are low-degree by applying them to random /// low-degree witness polynomials. -pub fn test_stark_low_degree, S: Stark, const D: usize>( +pub(crate) fn test_stark_low_degree< + F: RichField + Extendable, + S: Stark, + const D: usize, +>( stark: S, ) -> Result<()> { let rate_bits = log2_ceil(stark.constraint_degree() + 1); @@ -70,7 +74,7 @@ pub fn test_stark_low_degree, S: Stark, const } /// Tests that the circuit constraints imposed by the given STARK are coherent with the native constraints. -pub fn test_stark_circuit_constraints< +pub(crate) fn test_stark_circuit_constraints< F: RichField + Extendable, C: GenericConfig, S: Stark, diff --git a/evm/src/util.rs b/evm/src/util.rs index 08233056b1..a93f511b88 100644 --- a/evm/src/util.rs +++ b/evm/src/util.rs @@ -14,7 +14,7 @@ use plonky2::util::transpose; use crate::witness::errors::ProgramError; /// Construct an integer from its constituent bits (in little-endian order) -pub fn limb_from_bits_le(iter: impl IntoIterator) -> P { +pub(crate) fn limb_from_bits_le(iter: impl IntoIterator) -> P { // TODO: This is technically wrong, as 1 << i won't be canonical for all fields... iter.into_iter() .enumerate() @@ -23,7 +23,7 @@ pub fn limb_from_bits_le(iter: impl IntoIterator) -> P } /// Construct an integer from its constituent bits (in little-endian order): recursive edition -pub fn limb_from_bits_le_recursive, const D: usize>( +pub(crate) fn limb_from_bits_le_recursive, const D: usize>( builder: &mut plonky2::plonk::circuit_builder::CircuitBuilder, iter: impl IntoIterator>, ) -> ExtensionTarget { @@ -36,7 +36,7 @@ pub fn limb_from_bits_le_recursive, const D: usize> } /// A helper function to transpose a row-wise trace and put it in the format that `prove` expects. -pub fn trace_rows_to_poly_values( +pub(crate) fn trace_rows_to_poly_values( trace_rows: Vec<[F; COLUMNS]>, ) -> Vec> { let trace_row_vecs = trace_rows.into_iter().map(|row| row.to_vec()).collect_vec(); @@ -75,7 +75,6 @@ pub(crate) fn u256_to_usize(u256: U256) -> Result { u256.try_into().map_err(|_| ProgramError::IntegerTooLarge) } -#[allow(unused)] // TODO: Remove? /// Returns the 32-bit little-endian limbs of a `U256`. pub(crate) fn u256_limbs(u256: U256) -> [F; 8] { u256.0 @@ -91,7 +90,6 @@ pub(crate) fn u256_limbs(u256: U256) -> [F; 8] { .unwrap() } -#[allow(unused)] /// Returns the 32-bit little-endian limbs of a `H256`. pub(crate) fn h256_limbs(h256: H256) -> [F; 8] { let mut temp_h256 = h256.0; @@ -105,7 +103,6 @@ pub(crate) fn h256_limbs(h256: H256) -> [F; 8] { .unwrap() } -#[allow(unused)] /// Returns the 32-bit limbs of a `U160`. pub(crate) fn h160_limbs(h160: H160) -> [F; 5] { h160.0 diff --git a/evm/src/witness/errors.rs b/evm/src/witness/errors.rs index ccfefc65e2..dd1b54c214 100644 --- a/evm/src/witness/errors.rs +++ b/evm/src/witness/errors.rs @@ -1,6 +1,5 @@ use ethereum_types::U256; -#[allow(dead_code)] #[derive(Debug)] pub enum ProgramError { OutOfGas, diff --git a/evm/src/witness/memory.rs b/evm/src/witness/memory.rs index 5d589934a0..bec3a13359 100644 --- a/evm/src/witness/memory.rs +++ b/evm/src/witness/memory.rs @@ -17,7 +17,7 @@ use crate::witness::errors::ProgramError; use crate::witness::errors::ProgramError::MemoryError; impl MemoryChannel { - pub fn index(&self) -> usize { + pub(crate) fn index(&self) -> usize { match *self { Code => 0, GeneralPurpose(n) => { @@ -29,7 +29,7 @@ impl MemoryChannel { } #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] -pub struct MemoryAddress { +pub(crate) struct MemoryAddress { pub(crate) context: usize, pub(crate) segment: usize, pub(crate) virt: usize, @@ -79,7 +79,7 @@ pub enum MemoryOpKind { } #[derive(Clone, Copy, Debug)] -pub struct MemoryOp { +pub(crate) struct MemoryOp { /// true if this is an actual memory operation, or false if it's a padding row. pub filter: bool, pub timestamp: usize, @@ -101,7 +101,7 @@ pub static DUMMY_MEMOP: MemoryOp = MemoryOp { }; impl MemoryOp { - pub fn new( + pub(crate) fn new( channel: MemoryChannel, clock: usize, address: MemoryAddress, @@ -139,19 +139,19 @@ impl MemoryOp { } #[derive(Clone, Debug)] -pub struct MemoryState { +pub(crate) struct MemoryState { pub(crate) contexts: Vec, } impl MemoryState { - pub fn new(kernel_code: &[u8]) -> Self { + pub(crate) fn new(kernel_code: &[u8]) -> Self { let code_u256s = kernel_code.iter().map(|&x| x.into()).collect(); let mut result = Self::default(); result.contexts[0].segments[Segment::Code as usize].content = code_u256s; result } - pub fn apply_ops(&mut self, ops: &[MemoryOp]) { + pub(crate) fn apply_ops(&mut self, ops: &[MemoryOp]) { for &op in ops { let MemoryOp { address, @@ -165,7 +165,7 @@ impl MemoryState { } } - pub fn get(&self, address: MemoryAddress) -> U256 { + pub(crate) fn get(&self, address: MemoryAddress) -> U256 { if address.context >= self.contexts.len() { return U256::zero(); } @@ -182,7 +182,7 @@ impl MemoryState { val } - pub fn set(&mut self, address: MemoryAddress, val: U256) { + pub(crate) fn set(&mut self, address: MemoryAddress, val: U256) { while address.context >= self.contexts.len() { self.contexts.push(MemoryContextState::default()); } diff --git a/evm/src/witness/traces.rs b/evm/src/witness/traces.rs index 1a2b855c28..d6667a38e4 100644 --- a/evm/src/witness/traces.rs +++ b/evm/src/witness/traces.rs @@ -19,7 +19,7 @@ use crate::witness::memory::MemoryOp; use crate::{arithmetic, keccak, keccak_sponge, logic}; #[derive(Clone, Copy, Debug)] -pub struct TraceCheckpoint { +pub(crate) struct TraceCheckpoint { pub(self) arithmetic_len: usize, pub(self) byte_packing_len: usize, pub(self) cpu_len: usize, @@ -41,7 +41,7 @@ pub(crate) struct Traces { } impl Traces { - pub fn new() -> Self { + pub(crate) fn new() -> Self { Traces { arithmetic_ops: vec![], byte_packing_ops: vec![], @@ -55,7 +55,7 @@ impl Traces { /// Returns the actual trace lengths for each STARK module. // Uses a `TraceCheckPoint` as return object for convenience. - pub fn get_lengths(&self) -> TraceCheckpoint { + pub(crate) fn get_lengths(&self) -> TraceCheckpoint { TraceCheckpoint { arithmetic_len: self .arithmetic_ops @@ -85,7 +85,7 @@ impl Traces { } /// Returns the number of operations for each STARK module. - pub fn checkpoint(&self) -> TraceCheckpoint { + pub(crate) fn checkpoint(&self) -> TraceCheckpoint { TraceCheckpoint { arithmetic_len: self.arithmetic_ops.len(), byte_packing_len: self.byte_packing_ops.len(), @@ -97,7 +97,7 @@ impl Traces { } } - pub fn rollback(&mut self, checkpoint: TraceCheckpoint) { + pub(crate) fn rollback(&mut self, checkpoint: TraceCheckpoint) { self.arithmetic_ops.truncate(checkpoint.arithmetic_len); self.byte_packing_ops.truncate(checkpoint.byte_packing_len); self.cpu.truncate(checkpoint.cpu_len); @@ -108,35 +108,39 @@ impl Traces { self.memory_ops.truncate(checkpoint.memory_len); } - pub fn mem_ops_since(&self, checkpoint: TraceCheckpoint) -> &[MemoryOp] { + pub(crate) fn mem_ops_since(&self, checkpoint: TraceCheckpoint) -> &[MemoryOp] { &self.memory_ops[checkpoint.memory_len..] } - pub fn push_cpu(&mut self, val: CpuColumnsView) { + pub(crate) fn push_cpu(&mut self, val: CpuColumnsView) { self.cpu.push(val); } - pub fn push_logic(&mut self, op: logic::Operation) { + pub(crate) fn push_logic(&mut self, op: logic::Operation) { self.logic_ops.push(op); } - pub fn push_arithmetic(&mut self, op: arithmetic::Operation) { + pub(crate) fn push_arithmetic(&mut self, op: arithmetic::Operation) { self.arithmetic_ops.push(op); } - pub fn push_memory(&mut self, op: MemoryOp) { + pub(crate) fn push_memory(&mut self, op: MemoryOp) { self.memory_ops.push(op); } - pub fn push_byte_packing(&mut self, op: BytePackingOp) { + pub(crate) fn push_byte_packing(&mut self, op: BytePackingOp) { self.byte_packing_ops.push(op); } - pub fn push_keccak(&mut self, input: [u64; keccak::keccak_stark::NUM_INPUTS], clock: usize) { + pub(crate) fn push_keccak( + &mut self, + input: [u64; keccak::keccak_stark::NUM_INPUTS], + clock: usize, + ) { self.keccak_inputs.push((input, clock)); } - pub fn push_keccak_bytes(&mut self, input: [u8; KECCAK_WIDTH_BYTES], clock: usize) { + pub(crate) fn push_keccak_bytes(&mut self, input: [u8; KECCAK_WIDTH_BYTES], clock: usize) { let chunks = input .chunks(size_of::()) .map(|chunk| u64::from_le_bytes(chunk.try_into().unwrap())) @@ -146,15 +150,15 @@ impl Traces { self.push_keccak(chunks, clock); } - pub fn push_keccak_sponge(&mut self, op: KeccakSpongeOp) { + pub(crate) fn push_keccak_sponge(&mut self, op: KeccakSpongeOp) { self.keccak_sponge_ops.push(op); } - pub fn clock(&self) -> usize { + pub(crate) fn clock(&self) -> usize { self.cpu.len() } - pub fn into_tables( + pub(crate) fn into_tables( self, all_stark: &AllStark, config: &StarkConfig,