Skip to content

Commit

Permalink
fix set_jumpdest_analysis_inputs_rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
einar-polygon committed Oct 3, 2024
1 parent 27b5719 commit eaf3ed7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions evm_arithmetization/src/cpu/kernel/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub(crate) fn simulate_cpu_and_get_user_jumps<F: RichField>(

let (a, jdtw) = interpreter
.generation_state
.set_jumpdest_analysis_inputs(interpreter.jumpdest_table.clone());
.get_jumpdest_analysis_inputs(interpreter.jumpdest_table.clone());

log::debug!(
"Simulated CPU for jumpdest analysis halted after {:?} cycles.",
Expand Down Expand Up @@ -163,7 +163,7 @@ pub(crate) fn set_registers_and_run<F: RichField>(
///
/// - `jumpdest_table_rpc`: The raw table received from RPC.
/// - `code_db`: The corresponding database of contract code used in the trace.
pub(crate) fn set_jumpdest_analysis_inputs_rpc(
pub(crate) fn get_jumpdest_analysis_inputs_rpc(
jumpdest_table_rpc: &JumpDestTableWitness,
code_map: &HashMap<H256, Vec<u8>>,
) -> JumpDestTableProcessed {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ use crate::witness::operation::CONTEXT_SCALING_FACTOR;

impl<F: RichField> Interpreter<F> {
pub(crate) fn set_jumpdest_analysis_inputs(&mut self, jumps: HashMap<usize, BTreeSet<usize>>) {
let _ = self.generation_state.set_jumpdest_analysis_inputs(jumps);
let (jdtp, _jdtw) = self.generation_state.get_jumpdest_analysis_inputs(jumps);
self.generation_state.jumpdest_table = Some(jdtp);
}

pub(crate) fn get_jumpdest_bit(&self, offset: usize) -> U256 {
Expand Down
8 changes: 5 additions & 3 deletions evm_arithmetization/src/generation/prover_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::cpu::kernel::constants::cancun_constants::{
};
use crate::cpu::kernel::constants::context_metadata::ContextMetadata;
use crate::cpu::kernel::interpreter::{
set_jumpdest_analysis_inputs_rpc, simulate_cpu_and_get_user_jumps,
get_jumpdest_analysis_inputs_rpc, simulate_cpu_and_get_user_jumps,
};
use crate::curve_pairings::{bls381, CurveAff, CyclicGroup};
use crate::extension_tower::{FieldExt, Fp12, Fp2, BLS381, BLS_BASE, BLS_SCALAR, BN254, BN_BASE};
Expand Down Expand Up @@ -798,11 +798,13 @@ impl<F: RichField> GenerationState<F> {
// Simulate the user's code and (unnecessarily) part of the kernel code,
// skipping the validate table call

// REVIEW: This will be rewritten to only run simulation when
// `self.inputs.jumpdest_table` is `None`.
info!("Generating JUMPDEST tables");
let rpcw = self.inputs.jumpdest_table.clone();
let rpcp: Option<JumpDestTableProcessed> = rpcw
.as_ref()
.map(|jdt| set_jumpdest_analysis_inputs_rpc(jdt, &self.inputs.contract_code));
.map(|jdt| get_jumpdest_analysis_inputs_rpc(jdt, &self.inputs.contract_code));
info!("Generating JUMPDEST tables: Running SIM");

self.inputs.jumpdest_table = None;
Expand All @@ -826,7 +828,7 @@ impl<F: RichField> GenerationState<F> {
/// Given a HashMap containing the contexts and the jumpdest addresses,
/// compute their respective proofs, by calling
/// `get_proofs_and_jumpdests`
pub(crate) fn set_jumpdest_analysis_inputs(
pub(crate) fn get_jumpdest_analysis_inputs(
&self,
jumpdest_table: HashMap<usize, BTreeSet<usize>>,
) -> (JumpDestTableProcessed, JumpDestTableWitness) {
Expand Down

0 comments on commit eaf3ed7

Please sign in to comment.