From 92aaa404da05bd51434cbea3f15415007ed8eb82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alonso=20Gonz=C3=A1lez?= Date: Wed, 10 Jan 2024 13:55:09 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Robin Salen <30937548+Nashtare@users.noreply.github.com> --- evm/src/cpu/kernel/asm/core/jumpdest_analysis.asm | 4 ++-- evm/src/generation/mod.rs | 2 +- evm/src/generation/prover_input.rs | 6 +++--- evm/src/generation/state.rs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/evm/src/cpu/kernel/asm/core/jumpdest_analysis.asm b/evm/src/cpu/kernel/asm/core/jumpdest_analysis.asm index ed9bb06f..aed6c186 100644 --- a/evm/src/cpu/kernel/asm/core/jumpdest_analysis.asm +++ b/evm/src/cpu/kernel/asm/core/jumpdest_analysis.asm @@ -41,7 +41,7 @@ continue: proof_ok: // stack: i, ctx, final_pos, retdest - // We already know final pos is a jumpdest + // We already know final_pos is a jumpdest %stack (i, ctx, final_pos) -> (ctx, @SEGMENT_JUMPDEST_BITS, i) %build_address PUSH 1 @@ -99,7 +99,7 @@ code_bytes_to_skip: %endrep -// A proof attesting that jumpdest is a valid jump destinations is +// A proof attesting that jumpdest is a valid jump destination is // either 0 or an index 0 < i <= jumpdest - 32. // A proof is valid if: // - i == 0 and we can go from the first opcode to jumpdest and code[jumpdest] = 0x5b diff --git a/evm/src/generation/mod.rs b/evm/src/generation/mod.rs index 318c7d4f..238011d8 100644 --- a/evm/src/generation/mod.rs +++ b/evm/src/generation/mod.rs @@ -364,7 +364,7 @@ fn simulate_cpu_between_labels_and_get_user_jumps( log::debug!("Simulating CPU for jumpdest analysis."); loop { - // skip jumdest table validations in simulations + // skip jumpdest table validations in simulations if state.registers.program_counter == KERNEL.global_labels["jumpdest_analysis"] { state.registers.program_counter = KERNEL.global_labels["jumpdest_analysis_end"] } diff --git a/evm/src/generation/prover_input.rs b/evm/src/generation/prover_input.rs index b5541f1b..97177a8c 100644 --- a/evm/src/generation/prover_input.rs +++ b/evm/src/generation/prover_input.rs @@ -247,7 +247,8 @@ impl GenerationState { _ => Err(ProgramError::ProverInputError(InvalidInput)), } } - /// Return the next used jump addres + + /// Returns the next used jump address. fn run_next_jumpdest_table_address(&mut self) -> Result { let context = self.registers.context; let code_len = u256_to_usize(self.get_code_len()?.into()); @@ -299,7 +300,6 @@ impl GenerationState { let code = self.get_current_code()?; // We need to set the simulated jumpdest bits to one as otherwise // the simulation will fail. - // self.set_jumpdest_bits(&code); // Simulate the user's code and (unnecessarily) part of the kernel code, skipping the validate table call let Some(jumpdest_table) = simulate_cpu_between_labels_and_get_user_jumps( @@ -383,7 +383,7 @@ impl GenerationState { /// 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 -/// a vector of even size containing proofs followed by their addresses +/// a vector of even size containing proofs followed by their addresses. fn get_proofs_and_jumpdests( code: &[u8], largest_address: usize, diff --git a/evm/src/generation/state.rs b/evm/src/generation/state.rs index f844c5ce..f15ab317 100644 --- a/evm/src/generation/state.rs +++ b/evm/src/generation/state.rs @@ -169,7 +169,7 @@ impl GenerationState { .collect() } - /// Clone everything but the traces + /// Clones everything but the traces. pub(crate) fn soft_clone(&self) -> GenerationState { Self { inputs: self.inputs.clone(),