From e61e34bc26c10569416f91d3cb255cc71b203af7 Mon Sep 17 00:00:00 2001 From: Robin Salen Date: Fri, 17 Nov 2023 15:32:32 -0500 Subject: [PATCH] Reduce visibility --- evm/src/arithmetic/columns.rs | 6 +++--- evm/src/cpu/clock.rs | 4 ++-- evm/src/cpu/columns/general.rs | 2 +- evm/src/cpu/columns/mod.rs | 4 ++-- evm/src/cpu/columns/ops.rs | 2 +- evm/src/cpu/cpu_stark.rs | 4 ++-- evm/src/cpu/kernel/constants/exc_bitfields.rs | 4 ++-- evm/src/cpu/membus.rs | 8 ++++---- evm/src/cpu/stack_bounds.rs | 2 +- evm/src/extension_tower.rs | 4 ++-- evm/src/keccak/columns.rs | 4 ++-- evm/src/keccak_sponge/columns.rs | 2 +- evm/src/logic.rs | 14 +++++++------- evm/src/memory/segments.rs | 2 +- evm/src/proof.rs | 4 ++-- evm/src/witness/memory.rs | 6 +++--- 16 files changed, 36 insertions(+), 36 deletions(-) diff --git a/evm/src/arithmetic/columns.rs b/evm/src/arithmetic/columns.rs index 3736445433..bcfb29c177 100644 --- a/evm/src/arithmetic/columns.rs +++ b/evm/src/arithmetic/columns.rs @@ -2,7 +2,7 @@ use std::ops::Range; -pub const LIMB_BITS: usize = 16; +pub(crate) const LIMB_BITS: usize = 16; const EVM_REGISTER_BITS: usize = 256; /// Return the number of LIMB_BITS limbs that are in an EVM @@ -20,7 +20,7 @@ const fn n_limbs() -> usize { } /// Number of LIMB_BITS limbs that are in on EVM register-sized number. -pub const N_LIMBS: usize = n_limbs(); +pub(crate) const N_LIMBS: usize = n_limbs(); pub(crate) const IS_ADD: usize = 0; pub(crate) const IS_MUL: usize = IS_ADD + 1; @@ -112,4 +112,4 @@ pub(crate) const RANGE_COUNTER: usize = START_SHARED_COLS + NUM_SHARED_COLS; pub(crate) const RC_FREQUENCIES: usize = RANGE_COUNTER + 1; /// Number of columns in `ArithmeticStark`. -pub const NUM_ARITH_COLUMNS: usize = START_SHARED_COLS + NUM_SHARED_COLS + 2; +pub(crate) const NUM_ARITH_COLUMNS: usize = START_SHARED_COLS + NUM_SHARED_COLS + 2; diff --git a/evm/src/cpu/clock.rs b/evm/src/cpu/clock.rs index 0e39cbde73..cd7b17d8ed 100644 --- a/evm/src/cpu/clock.rs +++ b/evm/src/cpu/clock.rs @@ -7,7 +7,7 @@ use crate::constraint_consumer::{ConstraintConsumer, RecursiveConstraintConsumer use crate::cpu::columns::CpuColumnsView; /// Check the correct updating of `clock`. -pub fn eval_packed( +pub(crate) fn eval_packed( lv: &CpuColumnsView

, nv: &CpuColumnsView

, yield_constr: &mut ConstraintConsumer

, @@ -20,7 +20,7 @@ pub fn eval_packed( /// Circuit version of `eval_packed`. /// Check the correct updating of `clock`. -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/columns/general.rs b/evm/src/cpu/columns/general.rs index cfc24f51c6..234a592796 100644 --- a/evm/src/cpu/columns/general.rs +++ b/evm/src/cpu/columns/general.rs @@ -151,4 +151,4 @@ pub(crate) struct CpuStackView { /// Number of columns shared by all the views of `CpuGeneralColumnsView`. /// `u8` is guaranteed to have a `size_of` of 1. -pub const NUM_SHARED_COLUMNS: usize = size_of::>(); +pub(crate) const NUM_SHARED_COLUMNS: usize = size_of::>(); diff --git a/evm/src/cpu/columns/mod.rs b/evm/src/cpu/columns/mod.rs index 825ce9ca45..4a03f61d9e 100644 --- a/evm/src/cpu/columns/mod.rs +++ b/evm/src/cpu/columns/mod.rs @@ -103,7 +103,7 @@ pub(crate) struct CpuColumnsView { /// Total number of columns in `CpuStark`. /// `u8` is guaranteed to have a `size_of` of 1. -pub const NUM_CPU_COLUMNS: usize = size_of::>(); +pub(crate) const NUM_CPU_COLUMNS: usize = size_of::>(); impl Default for CpuColumnsView { fn default() -> Self { @@ -175,4 +175,4 @@ const fn make_col_map() -> CpuColumnsView { } /// Mapping between [0..NUM_CPU_COLUMNS-1] and the CPU columns. -pub const COL_MAP: CpuColumnsView = make_col_map(); +pub(crate) const COL_MAP: CpuColumnsView = make_col_map(); diff --git a/evm/src/cpu/columns/ops.rs b/evm/src/cpu/columns/ops.rs index c3b1e2641e..73f501d734 100644 --- a/evm/src/cpu/columns/ops.rs +++ b/evm/src/cpu/columns/ops.rs @@ -53,7 +53,7 @@ pub(crate) struct OpsColumnsView { /// Number of columns in Cpu Stark. /// `u8` is guaranteed to have a `size_of` of 1. -pub const NUM_OPS_COLUMNS: usize = size_of::>(); +pub(crate) const NUM_OPS_COLUMNS: usize = size_of::>(); impl From<[T; NUM_OPS_COLUMNS]> for OpsColumnsView { fn from(value: [T; NUM_OPS_COLUMNS]) -> Self { diff --git a/evm/src/cpu/cpu_stark.rs b/evm/src/cpu/cpu_stark.rs index 891d1d3827..893509dc06 100644 --- a/evm/src/cpu/cpu_stark.rs +++ b/evm/src/cpu/cpu_stark.rs @@ -185,9 +185,9 @@ pub(crate) fn ctl_filter_byte_packing_push() -> Column { } /// Index of the memory channel storing code. -pub const MEM_CODE_CHANNEL_IDX: usize = 0; +pub(crate) const MEM_CODE_CHANNEL_IDX: usize = 0; /// Index of the first general purpose memory channel. -pub const MEM_GP_CHANNELS_IDX_START: usize = MEM_CODE_CHANNEL_IDX + 1; +pub(crate) const MEM_GP_CHANNELS_IDX_START: usize = MEM_CODE_CHANNEL_IDX + 1; /// Make the time/channel column for memory lookups. fn mem_time_and_channel(channel: usize) -> Column { diff --git a/evm/src/cpu/kernel/constants/exc_bitfields.rs b/evm/src/cpu/kernel/constants/exc_bitfields.rs index 6751d96332..6054bf9bcc 100644 --- a/evm/src/cpu/kernel/constants/exc_bitfields.rs +++ b/evm/src/cpu/kernel/constants/exc_bitfields.rs @@ -28,7 +28,7 @@ const fn u256_from_set_index_ranges(ranges: &[RangeInclusive U256(res_limbs) } -pub const STACK_LENGTH_INCREASING_OPCODES_USER: U256 = u256_from_set_index_ranges(&[ +pub(crate) const STACK_LENGTH_INCREASING_OPCODES_USER: U256 = u256_from_set_index_ranges(&[ 0x30..=0x30, // ADDRESS 0x32..=0x34, // ORIGIN, CALLER, CALLVALUE 0x36..=0x36, // CALLDATASIZE @@ -40,7 +40,7 @@ pub const STACK_LENGTH_INCREASING_OPCODES_USER: U256 = u256_from_set_index_range 0x5f..=0x8f, // PUSH*, DUP* ]); -pub const INVALID_OPCODES_USER: U256 = u256_from_set_index_ranges(&[ +pub(crate) const INVALID_OPCODES_USER: U256 = u256_from_set_index_ranges(&[ 0x0c..=0x0f, 0x1e..=0x1f, 0x21..=0x2f, diff --git a/evm/src/cpu/membus.rs b/evm/src/cpu/membus.rs index 5b11ca25ff..a9041c060e 100644 --- a/evm/src/cpu/membus.rs +++ b/evm/src/cpu/membus.rs @@ -7,14 +7,14 @@ use crate::constraint_consumer::{ConstraintConsumer, RecursiveConstraintConsumer use crate::cpu::columns::CpuColumnsView; /// General-purpose memory channels; they can read and write to all contexts/segments/addresses. -pub const NUM_GP_CHANNELS: usize = 4; +pub(crate) const NUM_GP_CHANNELS: usize = 4; /// Indices for code and general purpose memory channels. pub mod channel_indices { use std::ops::Range; - pub const CODE: usize = 0; - pub const GP: Range = CODE + 1..(CODE + 1) + super::NUM_GP_CHANNELS; + pub(crate) const CODE: usize = 0; + pub(crate) const GP: Range = CODE + 1..(CODE + 1) + super::NUM_GP_CHANNELS; } /// Total memory channels used by the CPU table. This includes all the `GP_MEM_CHANNELS` as well as @@ -30,7 +30,7 @@ pub mod channel_indices { /// - the value must fit in one byte (in the least-significant position) and its eight bits are /// found in `opcode_bits`. /// These limitations save us numerous columns in the CPU table. -pub const NUM_CHANNELS: usize = channel_indices::GP.end; +pub(crate) const NUM_CHANNELS: usize = channel_indices::GP.end; /// Evaluates constraints regarding the membus. pub(crate) fn eval_packed( diff --git a/evm/src/cpu/stack_bounds.rs b/evm/src/cpu/stack_bounds.rs index a99760e5c4..59d6ff9a63 100644 --- a/evm/src/cpu/stack_bounds.rs +++ b/evm/src/cpu/stack_bounds.rs @@ -18,7 +18,7 @@ use super::columns::COL_MAP; use crate::constraint_consumer::{ConstraintConsumer, RecursiveConstraintConsumer}; use crate::cpu::columns::CpuColumnsView; -pub const MAX_USER_STACK_SIZE: usize = 1024; +pub(crate) const MAX_USER_STACK_SIZE: usize = 1024; /// Evaluates constraints to check for stack overflows. pub(crate) fn eval_packed( diff --git a/evm/src/extension_tower.rs b/evm/src/extension_tower.rs index 8faa0e8d03..4e5f54e67b 100644 --- a/evm/src/extension_tower.rs +++ b/evm/src/extension_tower.rs @@ -21,7 +21,7 @@ pub trait FieldExt: fn inv(self) -> Self; } -pub const BN_BASE: U256 = U256([ +pub(crate) const BN_BASE: U256 = U256([ 0x3c208c16d87cfd47, 0x97816a916871ca8d, 0xb85045b68181585d, @@ -114,7 +114,7 @@ impl Div for BN254 { } } -pub const BLS_BASE: U512 = U512([ +pub(crate) const BLS_BASE: U512 = U512([ 0xb9feffffffffaaab, 0x1eabfffeb153ffff, 0x6730d2a0f6b0f624, diff --git a/evm/src/keccak/columns.rs b/evm/src/keccak/columns.rs index cd801ebc08..bcdf0190ba 100644 --- a/evm/src/keccak/columns.rs +++ b/evm/src/keccak/columns.rs @@ -4,7 +4,7 @@ use crate::cross_table_lookup::Column; use crate::keccak::keccak_stark::{NUM_INPUTS, NUM_ROUNDS}; /// A register which is set to 1 if we are in the `i`th round, otherwise 0. -pub const fn reg_step(i: usize) -> usize { +pub(crate) const fn reg_step(i: usize) -> usize { debug_assert!(i < NUM_ROUNDS); i } @@ -28,7 +28,7 @@ pub(crate) fn reg_input_limb(i: usize) -> Column { /// Registers to hold permutation outputs. /// `reg_output_limb(2*i) -> output[i] as u32` /// `reg_output_limb(2*i+1) -> output[i] >> 32` -pub const fn reg_output_limb(i: usize) -> usize { +pub(crate) const fn reg_output_limb(i: usize) -> usize { debug_assert!(i < 2 * NUM_INPUTS); let i_u64 = i / 2; // The index of the 64-bit chunk. diff --git a/evm/src/keccak_sponge/columns.rs b/evm/src/keccak_sponge/columns.rs index 563c8449c8..7ba0cf4559 100644 --- a/evm/src/keccak_sponge/columns.rs +++ b/evm/src/keccak_sponge/columns.rs @@ -82,7 +82,7 @@ pub(crate) struct KeccakSpongeColumnsView { // `u8` is guaranteed to have a `size_of` of 1. /// Number of columns in `KeccakSpongeStark`. -pub const NUM_KECCAK_SPONGE_COLUMNS: usize = size_of::>(); +pub(crate) const NUM_KECCAK_SPONGE_COLUMNS: usize = size_of::>(); // Indices for LogUp range-check. // They are on the last registers of this table. diff --git a/evm/src/logic.rs b/evm/src/logic.rs index c45a9f4bf1..03737190a8 100644 --- a/evm/src/logic.rs +++ b/evm/src/logic.rs @@ -34,17 +34,17 @@ pub(crate) mod columns { use super::{PACKED_LEN, PACKED_LIMB_BITS, VAL_BITS}; /// 1 if this is an AND operation, 0 otherwise. - pub const IS_AND: usize = 0; + pub(crate) const IS_AND: usize = 0; /// 1 if this is an OR operation, 0 otherwise. - pub const IS_OR: usize = IS_AND + 1; + pub(crate) const IS_OR: usize = IS_AND + 1; /// 1 if this is a XOR operation, 0 otherwise. - pub const IS_XOR: usize = IS_OR + 1; + pub(crate) const IS_XOR: usize = IS_OR + 1; /// First input, decomposed into bits. - pub const INPUT0: Range = (IS_XOR + 1)..(IS_XOR + 1) + VAL_BITS; + pub(crate) const INPUT0: Range = (IS_XOR + 1)..(IS_XOR + 1) + VAL_BITS; /// Second input, decomposed into bits. - pub const INPUT1: Range = INPUT0.end..INPUT0.end + VAL_BITS; + pub(crate) const INPUT1: Range = INPUT0.end..INPUT0.end + VAL_BITS; /// The result is packed in limbs of `PACKED_LIMB_BITS` bits. - pub const RESULT: Range = INPUT1.end..INPUT1.end + PACKED_LEN; + pub(crate) const RESULT: Range = INPUT1.end..INPUT1.end + PACKED_LEN; /// Returns the column range for each 32 bit chunk in the input. pub(crate) fn limb_bit_cols_for_input( @@ -58,7 +58,7 @@ pub(crate) mod columns { } /// Number of columns in `LogicStark`. - pub const NUM_COLUMNS: usize = RESULT.end; + pub(crate) const NUM_COLUMNS: usize = RESULT.end; } /// Creates the vector of `Columns` corresponding to the opcode, the two inputs and the output of the logic operation. diff --git a/evm/src/memory/segments.rs b/evm/src/memory/segments.rs index 855f7218ab..06a9eea767 100644 --- a/evm/src/memory/segments.rs +++ b/evm/src/memory/segments.rs @@ -1,5 +1,5 @@ #[derive(Copy, Clone, Eq, PartialEq, Hash, Ord, PartialOrd, Debug)] -pub enum Segment { +pub(crate) enum Segment { /// Contains EVM bytecode. Code = 0, /// The program stack. diff --git a/evm/src/proof.rs b/evm/src/proof.rs index 60f2ce4dc0..ea8507b1fb 100644 --- a/evm/src/proof.rs +++ b/evm/src/proof.rs @@ -385,7 +385,7 @@ pub(crate) struct TrieRootsTarget { impl TrieRootsTarget { /// Number of `Target`s required for all trie hashes. - pub const SIZE: usize = 24; + pub(crate) const SIZE: usize = 24; /// Extracts trie hash `Target`s for all tries from the provided public input `Target`s. /// The provided `pis` should start with the trie hashes. @@ -469,7 +469,7 @@ pub(crate) struct BlockMetadataTarget { impl BlockMetadataTarget { /// Number of `Target`s required for the block metadata. - pub const SIZE: usize = 85; + pub(crate) const SIZE: usize = 85; /// Extracts block metadata `Target`s from the provided public input `Target`s. /// The provided `pis` should start with the block metadata. diff --git a/evm/src/witness/memory.rs b/evm/src/witness/memory.rs index b7885a23dc..58b1f6c211 100644 --- a/evm/src/witness/memory.rs +++ b/evm/src/witness/memory.rs @@ -3,7 +3,7 @@ use ethereum_types::U256; use crate::cpu::membus::{NUM_CHANNELS, NUM_GP_CHANNELS}; #[derive(Clone, Copy, Debug)] -pub enum MemoryChannel { +pub(crate) enum MemoryChannel { Code, GeneralPurpose(usize), PartialChannel, @@ -75,7 +75,7 @@ impl MemoryAddress { } #[derive(Clone, Copy, Debug, Eq, PartialEq)] -pub enum MemoryOpKind { +pub(crate) enum MemoryOpKind { Read, Write, } @@ -90,7 +90,7 @@ pub(crate) struct MemoryOp { pub value: U256, } -pub static DUMMY_MEMOP: MemoryOp = MemoryOp { +pub(crate) static DUMMY_MEMOP: MemoryOp = MemoryOp { filter: false, timestamp: 0, address: MemoryAddress {