diff --git a/evm/src/generation/prover_input.rs b/evm/src/generation/prover_input.rs index ccec9c45..c8b78e62 100644 --- a/evm/src/generation/prover_input.rs +++ b/evm/src/generation/prover_input.rs @@ -312,7 +312,6 @@ impl GenerationState { 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 GenerationState { } } -/// 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, diff --git a/evm/src/generation/state.rs b/evm/src/generation/state.rs index f15ab317..ddc2f359 100644 --- a/evm/src/generation/state.rs +++ b/evm/src/generation/state.rs @@ -51,6 +51,10 @@ pub(crate) struct GenerationState { /// 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>>, }