Skip to content
This repository has been archived by the owner on Feb 21, 2024. It is now read-only.

Commit

Permalink
Reduce visibility (0xPolygonZero#1364)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nashtare authored Nov 17, 2023
1 parent ddecf8b commit b932881
Show file tree
Hide file tree
Showing 16 changed files with 36 additions and 36 deletions.
6 changes: 3 additions & 3 deletions evm/src/arithmetic/columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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;
4 changes: 2 additions & 2 deletions evm/src/cpu/clock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<P: PackedField>(
pub(crate) fn eval_packed<P: PackedField>(
lv: &CpuColumnsView<P>,
nv: &CpuColumnsView<P>,
yield_constr: &mut ConstraintConsumer<P>,
Expand All @@ -20,7 +20,7 @@ pub fn eval_packed<P: PackedField>(

/// Circuit version of `eval_packed`.
/// Check the correct updating of `clock`.
pub fn eval_ext_circuit<F: RichField + Extendable<D>, const D: usize>(
pub(crate) fn eval_ext_circuit<F: RichField + Extendable<D>, const D: usize>(
builder: &mut plonky2::plonk::circuit_builder::CircuitBuilder<F, D>,
lv: &CpuColumnsView<ExtensionTarget<D>>,
nv: &CpuColumnsView<ExtensionTarget<D>>,
Expand Down
2 changes: 1 addition & 1 deletion evm/src/cpu/columns/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,4 @@ pub(crate) struct CpuStackView<T: Copy> {

/// 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::<CpuGeneralColumnsView<u8>>();
pub(crate) const NUM_SHARED_COLUMNS: usize = size_of::<CpuGeneralColumnsView<u8>>();
4 changes: 2 additions & 2 deletions evm/src/cpu/columns/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub(crate) struct CpuColumnsView<T: Copy> {

/// Total number of columns in `CpuStark`.
/// `u8` is guaranteed to have a `size_of` of 1.
pub const NUM_CPU_COLUMNS: usize = size_of::<CpuColumnsView<u8>>();
pub(crate) const NUM_CPU_COLUMNS: usize = size_of::<CpuColumnsView<u8>>();

impl<F: Field> Default for CpuColumnsView<F> {
fn default() -> Self {
Expand Down Expand Up @@ -175,4 +175,4 @@ const fn make_col_map() -> CpuColumnsView<usize> {
}

/// Mapping between [0..NUM_CPU_COLUMNS-1] and the CPU columns.
pub const COL_MAP: CpuColumnsView<usize> = make_col_map();
pub(crate) const COL_MAP: CpuColumnsView<usize> = make_col_map();
2 changes: 1 addition & 1 deletion evm/src/cpu/columns/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub(crate) struct OpsColumnsView<T: Copy> {

/// Number of columns in Cpu Stark.
/// `u8` is guaranteed to have a `size_of` of 1.
pub const NUM_OPS_COLUMNS: usize = size_of::<OpsColumnsView<u8>>();
pub(crate) const NUM_OPS_COLUMNS: usize = size_of::<OpsColumnsView<u8>>();

impl<T: Copy> From<[T; NUM_OPS_COLUMNS]> for OpsColumnsView<T> {
fn from(value: [T; NUM_OPS_COLUMNS]) -> Self {
Expand Down
4 changes: 2 additions & 2 deletions evm/src/cpu/cpu_stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ pub(crate) fn ctl_filter_byte_packing_push<F: Field>() -> Column<F> {
}

/// 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<F: Field>(channel: usize) -> Column<F> {
Expand Down
4 changes: 2 additions & 2 deletions evm/src/cpu/kernel/constants/exc_bitfields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const fn u256_from_set_index_ranges<const N: usize>(ranges: &[RangeInclusive<u8>
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
Expand All @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions evm/src/cpu/membus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<usize> = CODE + 1..(CODE + 1) + super::NUM_GP_CHANNELS;
pub(crate) const CODE: usize = 0;
pub(crate) const GP: Range<usize> = 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
Expand All @@ -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<P: PackedField>(
Expand Down
2 changes: 1 addition & 1 deletion evm/src/cpu/stack_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<P: PackedField>(
Expand Down
4 changes: 2 additions & 2 deletions evm/src/extension_tower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -114,7 +114,7 @@ impl Div for BN254 {
}
}

pub const BLS_BASE: U512 = U512([
pub(crate) const BLS_BASE: U512 = U512([
0xb9feffffffffaaab,
0x1eabfffeb153ffff,
0x6730d2a0f6b0f624,
Expand Down
4 changes: 2 additions & 2 deletions evm/src/keccak/columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -28,7 +28,7 @@ pub(crate) fn reg_input_limb<F: Field>(i: usize) -> Column<F> {
/// 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.

Expand Down
2 changes: 1 addition & 1 deletion evm/src/keccak_sponge/columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub(crate) struct KeccakSpongeColumnsView<T: Copy> {

// `u8` is guaranteed to have a `size_of` of 1.
/// Number of columns in `KeccakSpongeStark`.
pub const NUM_KECCAK_SPONGE_COLUMNS: usize = size_of::<KeccakSpongeColumnsView<u8>>();
pub(crate) const NUM_KECCAK_SPONGE_COLUMNS: usize = size_of::<KeccakSpongeColumnsView<u8>>();

// Indices for LogUp range-check.
// They are on the last registers of this table.
Expand Down
14 changes: 7 additions & 7 deletions evm/src/logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<usize> = (IS_XOR + 1)..(IS_XOR + 1) + VAL_BITS;
pub(crate) const INPUT0: Range<usize> = (IS_XOR + 1)..(IS_XOR + 1) + VAL_BITS;
/// Second input, decomposed into bits.
pub const INPUT1: Range<usize> = INPUT0.end..INPUT0.end + VAL_BITS;
pub(crate) const INPUT1: Range<usize> = INPUT0.end..INPUT0.end + VAL_BITS;
/// The result is packed in limbs of `PACKED_LIMB_BITS` bits.
pub const RESULT: Range<usize> = INPUT1.end..INPUT1.end + PACKED_LEN;
pub(crate) const RESULT: Range<usize> = 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(
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion evm/src/memory/segments.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions evm/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions evm/src/witness/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -75,7 +75,7 @@ impl MemoryAddress {
}

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum MemoryOpKind {
pub(crate) enum MemoryOpKind {
Read,
Write,
}
Expand All @@ -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 {
Expand Down

0 comments on commit b932881

Please sign in to comment.