This commit is contained in:
4l0n50 2023-12-20 15:27:27 +01:00
parent 3e78865d64
commit 24ae0d9de0
2 changed files with 6 additions and 11 deletions

View File

@ -368,9 +368,9 @@ impl<F: Field> GenerationState<F> {
Ok(code_len)
}
fn set_jumpdest_bits<'a>(&mut self, code: &'a Vec<u8>) {
fn set_jumpdest_bits(&mut self, code: &[u8]) {
const JUMPDEST_OPCODE: u8 = 0x5b;
for (pos, opcode) in CodeIterator::new(&code) {
for (pos, opcode) in CodeIterator::new(code) {
if opcode == JUMPDEST_OPCODE {
self.memory.set(
MemoryAddress {
@ -390,14 +390,14 @@ impl<F: Field> GenerationState<F> {
/// for which none of the previous 32 bytes in the code (including opcodes
/// and pushed bytes are PUSHXX and the address is in its range. It returns
/// a vector of even size containing proofs followed by their addresses
fn get_proofs_and_jumpdests<'a>(
code: &'a Vec<u8>,
fn get_proofs_and_jumpdests(
code: &[u8],
largest_address: usize,
jumpdest_table: std::collections::BTreeSet<usize>,
) -> Vec<usize> {
const PUSH1_OPCODE: u8 = 0x60;
const PUSH32_OPCODE: u8 = 0x7f;
let (proofs, _) = CodeIterator::until(&code, largest_address + 1).fold(
let (proofs, _) = CodeIterator::until(code, largest_address + 1).fold(
(vec![], 0),
|(mut proofs, acc), (pos, opcode)| {
let has_prefix = if let Some(prefix_start) = pos.checked_sub(32) {

View File

@ -70,7 +70,7 @@ pub(crate) fn u256_to_u64<F: Field>(u256: U256) -> Result<(F, F), ProgramError>
))
}
/// Safe conversion from U256 to u8, which errors in case of overflow instead of panicking.
/// Safe conversion from U256 to u8, which errors in case of overflow.
pub(crate) fn u256_to_u8(u256: U256) -> Result<u8, ProgramError> {
u256.try_into().map_err(|_| ProgramError::IntegerTooLarge)
}
@ -80,11 +80,6 @@ pub(crate) fn u256_to_usize(u256: U256) -> Result<usize, ProgramError> {
u256.try_into().map_err(|_| ProgramError::IntegerTooLarge)
}
/// Converts a `U256` to a `u8`, erroring in case of overlow instead of panicking.
pub(crate) fn u256_to_u8(u256: U256) -> Result<u8, ProgramError> {
u256.try_into().map_err(|_| ProgramError::IntegerTooLarge)
}
/// Converts a `U256` to a `bool`, erroring in case of overlow instead of panicking.
pub(crate) fn u256_to_bool(u256: U256) -> Result<bool, ProgramError> {
if u256 == U256::zero() {