Skip to content

Commit

Permalink
Mark constant functions with const (#571)
Browse files Browse the repository at this point in the history
Co-authored-by: Robin Salen <[email protected]>
  • Loading branch information
julianbraha and Nashtare committed Sep 6, 2024
1 parent 6f8199b commit 47c79ed
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion evm_arithmetization/src/cpu/columns/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl<T: Copy> CpuGeneralColumnsView<T> {

/// View of the column for context pruning.
/// SAFETY: Each view is a valid interpretation of the underlying array.
pub(crate) fn context_pruning(&self) -> &CpuContextPruningView<T> {
pub(crate) const fn context_pruning(&self) -> &CpuContextPruningView<T> {
unsafe { &self.context_pruning }
}

Expand Down
2 changes: 1 addition & 1 deletion evm_arithmetization/src/cpu/kernel/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ impl<F: Field> Interpreter<F> {
}

/// Returns the max number of CPU cycles.
pub(crate) fn get_max_cpu_len_log(&self) -> Option<usize> {
pub(crate) const fn get_max_cpu_len_log(&self) -> Option<usize> {
self.max_cpu_len_log
}

Expand Down
4 changes: 2 additions & 2 deletions evm_arithmetization/src/generation/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ pub(crate) fn empty_list_mem<const N: usize>(segment: Segment) -> [Option<U256>;
}

impl<'a, const N: usize> LinkedList<'a, N> {
pub fn from_mem_and_segment(
pub const fn from_mem_and_segment(
mem: &'a [Option<U256>],
segment: Segment,
) -> Result<Self, ProgramError> {
Self::from_mem_len_and_segment(mem, segment)
}

pub fn from_mem_len_and_segment(
pub const fn from_mem_len_and_segment(
mem: &'a [Option<U256>],
segment: Segment,
) -> Result<Self, ProgramError> {
Expand Down
2 changes: 1 addition & 1 deletion evm_arithmetization/src/generation/mpt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ fn parse_storage_value(value_rlp: &[u8]) -> Result<Vec<U256>, ProgramError> {
Ok(vec![value])
}

fn parse_storage_value_no_return(_value_rlp: &[u8]) -> Result<Vec<U256>, ProgramError> {
const fn parse_storage_value_no_return(_value_rlp: &[u8]) -> Result<Vec<U256>, ProgramError> {
Ok(vec![])
}

Expand Down
2 changes: 1 addition & 1 deletion evm_arithmetization/src/generation/segments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub struct GenerationSegmentData {

impl GenerationSegmentData {
/// Retrieves the index of this segment.
pub fn segment_index(&self) -> usize {
pub const fn segment_index(&self) -> usize {
self.segment_index
}
}
Expand Down
2 changes: 1 addition & 1 deletion evm_arithmetization/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ pub enum BurnAddrTarget {
}

impl BurnAddrTarget {
pub fn get_size() -> usize {
pub const fn get_size() -> usize {
match cfg!(feature = "cdk_erigon") {
true => 8,
false => 0,
Expand Down
4 changes: 2 additions & 2 deletions proof_gen/src/proof_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ impl BatchAggregatableProof {
}
}

pub(crate) fn is_agg(&self) -> bool {
pub(crate) const fn is_agg(&self) -> bool {
match self {
BatchAggregatableProof::Segment(_) => false,
BatchAggregatableProof::Txn(_) => false,
BatchAggregatableProof::Agg(_) => true,
}
}

pub(crate) fn intern(&self) -> &PlonkyProofIntern {
pub(crate) const fn intern(&self) -> &PlonkyProofIntern {
match self {
BatchAggregatableProof::Segment(info) => &info.intern,
BatchAggregatableProof::Txn(info) => &info.intern,
Expand Down
10 changes: 5 additions & 5 deletions trace_decoder/src/typed_mpt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl<T> TypedMpt<T> {
let bytes = self.inner.get(key.into_nibbles())?;
Some(rlp::decode(bytes).expect(Self::PANIC_MSG))
}
fn as_hashed_partial_trie(&self) -> &HashedPartialTrie {
const fn as_hashed_partial_trie(&self) -> &HashedPartialTrie {
&self.inner
}
fn as_mut_hashed_partial_trie_unchecked(&mut self) -> &mut HashedPartialTrie {
Expand Down Expand Up @@ -198,7 +198,7 @@ impl TransactionTrie {
pub fn root(&self) -> H256 {
self.untyped.hash()
}
pub fn as_hashed_partial_trie(&self) -> &mpt_trie::partial_trie::HashedPartialTrie {
pub const fn as_hashed_partial_trie(&self) -> &mpt_trie::partial_trie::HashedPartialTrie {
&self.untyped
}
}
Expand All @@ -224,7 +224,7 @@ impl ReceiptTrie {
pub fn root(&self) -> H256 {
self.untyped.hash()
}
pub fn as_hashed_partial_trie(&self) -> &mpt_trie::partial_trie::HashedPartialTrie {
pub const fn as_hashed_partial_trie(&self) -> &mpt_trie::partial_trie::HashedPartialTrie {
&self.untyped
}
}
Expand Down Expand Up @@ -259,7 +259,7 @@ impl StateMpt {
.iter()
.map(|(key, rlp)| (key.into_hash().expect("key is always H256"), rlp))
}
pub fn as_hashed_partial_trie(&self) -> &mpt_trie::partial_trie::HashedPartialTrie {
pub const fn as_hashed_partial_trie(&self) -> &mpt_trie::partial_trie::HashedPartialTrie {
self.typed.as_hashed_partial_trie()
}
pub fn root(&self) -> H256 {
Expand Down Expand Up @@ -392,7 +392,7 @@ impl StorageTrie {
pub fn root(&self) -> H256 {
self.untyped.hash()
}
pub fn as_hashed_partial_trie(&self) -> &HashedPartialTrie {
pub const fn as_hashed_partial_trie(&self) -> &HashedPartialTrie {
&self.untyped
}

Expand Down

0 comments on commit 47c79ed

Please sign in to comment.