mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-05 23:33:07 +00:00
Apply suggestions from code review
Co-authored-by: Robin Salen <30937548+Nashtare@users.noreply.github.com>
This commit is contained in:
parent
1715573c22
commit
92aaa404da
@ -41,7 +41,7 @@ continue:
|
|||||||
|
|
||||||
proof_ok:
|
proof_ok:
|
||||||
// stack: i, ctx, final_pos, retdest
|
// 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)
|
%stack (i, ctx, final_pos) -> (ctx, @SEGMENT_JUMPDEST_BITS, i)
|
||||||
%build_address
|
%build_address
|
||||||
PUSH 1
|
PUSH 1
|
||||||
@ -99,7 +99,7 @@ code_bytes_to_skip:
|
|||||||
%endrep
|
%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.
|
// either 0 or an index 0 < i <= jumpdest - 32.
|
||||||
// A proof is valid if:
|
// A proof is valid if:
|
||||||
// - i == 0 and we can go from the first opcode to jumpdest and code[jumpdest] = 0x5b
|
// - i == 0 and we can go from the first opcode to jumpdest and code[jumpdest] = 0x5b
|
||||||
|
|||||||
@ -364,7 +364,7 @@ fn simulate_cpu_between_labels_and_get_user_jumps<F: Field>(
|
|||||||
log::debug!("Simulating CPU for jumpdest analysis.");
|
log::debug!("Simulating CPU for jumpdest analysis.");
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
// skip jumdest table validations in simulations
|
// skip jumpdest table validations in simulations
|
||||||
if state.registers.program_counter == KERNEL.global_labels["jumpdest_analysis"] {
|
if state.registers.program_counter == KERNEL.global_labels["jumpdest_analysis"] {
|
||||||
state.registers.program_counter = KERNEL.global_labels["jumpdest_analysis_end"]
|
state.registers.program_counter = KERNEL.global_labels["jumpdest_analysis_end"]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -247,7 +247,8 @@ impl<F: Field> GenerationState<F> {
|
|||||||
_ => Err(ProgramError::ProverInputError(InvalidInput)),
|
_ => 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<U256, ProgramError> {
|
fn run_next_jumpdest_table_address(&mut self) -> Result<U256, ProgramError> {
|
||||||
let context = self.registers.context;
|
let context = self.registers.context;
|
||||||
let code_len = u256_to_usize(self.get_code_len()?.into());
|
let code_len = u256_to_usize(self.get_code_len()?.into());
|
||||||
@ -299,7 +300,6 @@ impl<F: Field> GenerationState<F> {
|
|||||||
let code = self.get_current_code()?;
|
let code = self.get_current_code()?;
|
||||||
// We need to set the simulated jumpdest bits to one as otherwise
|
// We need to set the simulated jumpdest bits to one as otherwise
|
||||||
// the simulation will fail.
|
// 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
|
// 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(
|
let Some(jumpdest_table) = simulate_cpu_between_labels_and_get_user_jumps(
|
||||||
@ -383,7 +383,7 @@ impl<F: Field> GenerationState<F> {
|
|||||||
/// this function searches for a proof. A proof is the closest 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
|
/// 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
|
/// 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(
|
fn get_proofs_and_jumpdests(
|
||||||
code: &[u8],
|
code: &[u8],
|
||||||
largest_address: usize,
|
largest_address: usize,
|
||||||
|
|||||||
@ -169,7 +169,7 @@ impl<F: Field> GenerationState<F> {
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clone everything but the traces
|
/// Clones everything but the traces.
|
||||||
pub(crate) fn soft_clone(&self) -> GenerationState<F> {
|
pub(crate) fn soft_clone(&self) -> GenerationState<F> {
|
||||||
Self {
|
Self {
|
||||||
inputs: self.inputs.clone(),
|
inputs: self.inputs.clone(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user