Missing review comments

This commit is contained in:
4l0n50 2024-01-10 17:58:41 +01:00
parent ae4a720a74
commit 99a1eb5c85
2 changed files with 13 additions and 7 deletions

View File

@ -312,7 +312,6 @@ impl<F: Field> GenerationState<F> {
self.jumpdest_proofs = Some(HashMap::new());
return Ok(());
};
log::debug!("jumpdest_table = {:?}", jumpdest_table);
// Return to the state before starting the simulation
self.rollback(checkpoint);
@ -383,7 +382,7 @@ impl<F: Field> GenerationState<F> {
}
}
/// For all address in `jumpdest_table`, each bounded by larges_address,
/// For all address in `jumpdest_table`, each bounded by `largest_address`,
/// this function searches for a proof. A proof is the closest address
/// 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
@ -403,11 +402,12 @@ fn get_proofs_and_jumpdests(
.iter()
.enumerate()
.fold(true, |acc, (prefix_pos, &byte)| {
acc && (byte > PUSH32_OPCODE
|| (prefix_start + prefix_pos) as i32
+ (byte as i32 - PUSH1_OPCODE as i32)
+ 1
< pos as i32)
let cond1 = byte > PUSH32_OPCODE;
let cond2 = (prefix_start + prefix_pos) as i32
+ (byte as i32 - PUSH1_OPCODE as i32)
+ 1
< pos as i32;
acc && (cond1 || cond2)
})
} else {
false
@ -425,6 +425,8 @@ fn get_proofs_and_jumpdests(
proofs
}
/// An iterator over the EVM code contained in `code`, which skips the bytes
/// that are the arguments of a PUSHXX opcode.
struct CodeIterator<'a> {
code: &'a [u8],
pos: usize,

View File

@ -51,6 +51,10 @@ pub(crate) struct GenerationState<F: Field> {
/// Pointers, within the `TrieData` segment, of the three MPTs.
pub(crate) trie_root_ptrs: TrieRootPtrs,
/// A hash map where the key is a context in the user's code and the value is the set of
/// jump destinations with its corresponding "proof". A "proof" for a jump destination is
/// either 0 or an address i > 32 in the code (not necessarily pointing to an opcode) such that
/// for every j in [i, i+32] it holds that code[j] < 0x7f - j + i.
pub(crate) jumpdest_proofs: Option<HashMap<usize, Vec<usize>>>,
}