Skip to content

Commit

Permalink
chore(keccak): format_requests always returns true capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanpwang committed Sep 28, 2023
1 parent 4cd0844 commit 1a68c98
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions hashes/zkevm/src/keccak/component/ingestion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ impl KeccakIngestionFormat {
/// Very similar to [crate::keccak::component::encode::encode_native_input] except we do not do the
/// encoding part (that will be done in circuit, not natively).
///
/// Returns `Err(true_capacity)` if `true_capacity > capacity`, where `true_capacity` is the number of keccak_f needed
/// to compute all requests.
/// Returns `(ingestions, true_capacity)`, where `ingestions` is resized to `capacity` length
/// and `true_capacity` is the number of keccak_f needed to compute all requests.
pub fn format_requests_for_ingestion<B>(
requests: impl IntoIterator<Item = (B, Option<H256>)>,
capacity: usize,
) -> Result<Vec<KeccakIngestionFormat>, usize>
) -> (Vec<KeccakIngestionFormat>, usize)
where
B: AsRef<[u8]>,
{
Expand Down Expand Up @@ -77,10 +77,7 @@ where
last_mut.hash_lo = u128::from_be_bytes(hash[16..].try_into().unwrap());
}
log::info!("Actual number of keccak_f used = {}", ingestions.len());
if ingestions.len() > capacity {
Err(ingestions.len())
} else {
ingestions.resize_with(capacity, Default::default);
Ok(ingestions)
}
let true_capacity = ingestions.len();
ingestions.resize_with(capacity, Default::default);
(ingestions, true_capacity)
}

0 comments on commit 1a68c98

Please sign in to comment.