Skip to content

Commit

Permalink
remove tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
einar-polygon committed Oct 21, 2024
1 parent 0b7e997 commit d67911e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 83 deletions.
9 changes: 1 addition & 8 deletions evm_arithmetization/src/cpu/kernel/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::collections::{BTreeSet, HashMap};
use anyhow::anyhow;
use ethereum_types::{BigEndianHash, U256};
use keccak_hash::H256;
use log::{trace, Level};
use log::Level;
use mpt_trie::partial_trie::PartialTrie;
use plonky2::hash::hash_types::RichField;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -177,13 +177,6 @@ pub(crate) fn get_jumpdest_analysis_inputs_rpc(
} else {
&vec![]
};
trace!(
"code: {:?}, code_addr: {:?}, {:?} <============",
&code,
&code_addr,
code_map.contains_key(code_addr),
);
trace!("code_map: {:?}", &code_map);
prove_context_jumpdests(code, ctx_jumpdests)
})
.collect();
Expand Down
14 changes: 2 additions & 12 deletions evm_arithmetization/src/generation/prover_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use anyhow::{bail, Error, Result};
use ethereum_types::{BigEndianHash, H256, U256, U512};
use itertools::Itertools;
use keccak_hash::keccak;
use log::{info, trace};
use num_bigint::BigUint;
use plonky2::hash::hash_types::RichField;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -792,10 +791,6 @@ impl<F: RichField> GenerationState<F> {
/// Simulate the user's code and store all the jump addresses with their
/// respective contexts.
fn generate_jumpdest_table(&mut self) -> Result<(), ProgramError> {
// Simulate the user's code and (unnecessarily) part of the kernel code,
// skipping the validate table call

info!("Generating JUMPDEST tables");
let rpcw = self.inputs.jumpdest_table.clone();
let rpcp: Option<JumpDestTableProcessed> = rpcw
.as_ref()
Expand All @@ -804,15 +799,11 @@ impl<F: RichField> GenerationState<F> {
self.jumpdest_table = rpcp;
return Ok(());
}

info!("Generating JUMPDEST tables: Running SIM");

// Simulate the user's code and (unnecessarily) part of the kernel code,
// skipping the validate table call
let (simp, _simw) = simulate_cpu_and_get_user_jumps("terminate_common", self)
.ok_or(ProgramError::ProverInputError(InvalidJumpdestSimulation))?;
self.jumpdest_table = Some(simp);

info!("Generating JUMPDEST tables: finished");

Ok(())
}

Expand All @@ -828,7 +819,6 @@ impl<F: RichField> GenerationState<F> {
|(ctx, jumpdest_table)| {
let code = self.get_code(ctx).unwrap();
let code_hash = keccak(code.clone());
trace!("ctx: {ctx}, code_hash: {:?} code: {:?}", code_hash, code);
for offset in jumpdest_table.clone() {
jdtw.insert(code_hash, ctx, offset);
}
Expand Down
4 changes: 0 additions & 4 deletions trace_decoder/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use evm_arithmetization::{
};
use itertools::Itertools as _;
use keccak_hash::H256;
use log::debug;
use mpt_trie::partial_trie::PartialTrie as _;
use nunny::NonEmpty;
use zk_evm_common::gwei_to_wei;
Expand Down Expand Up @@ -859,9 +858,6 @@ impl Hash2Code {
}
pub fn get(&mut self, hash: H256) -> Option<Vec<u8>> {
let res = self.inner.get(&hash).cloned();
if res.is_none() {
debug!("no code for hash {:#x}", hash);
}
res
}
pub fn insert(&mut self, code: Vec<u8>) {
Expand Down
61 changes: 2 additions & 59 deletions zero/src/rpc/jumpdest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use tokio::time::timeout;
use trace_decoder::is_precompile;
use trace_decoder::ContractCodeUsage;
use trace_decoder::TxnTrace;
use tracing::{trace, warn};
use tracing::warn;

use crate::rpc::H256;

Expand Down Expand Up @@ -70,7 +70,6 @@ where
match timeout(*fetch_timeout, block_stackonly_structlog_traces_fut).await {
Ok(traces) => traces?,
Err(elapsed) => {
trace!(target: "fetching block structlogs timed out", ?elapsed);
bail!(elapsed);
}
};
Expand All @@ -97,8 +96,6 @@ pub(crate) fn generate_jumpdest_table<'a>(
structlog: &[StructLog],
tx_traces: impl Iterator<Item = (Address, &'a TxnTrace)>,
) -> anyhow::Result<JumpDestTableWitness> {
trace!("Generating JUMPDEST table for tx: {}", tx.hash);

let mut jumpdest_table = JumpDestTableWitness::default();

// This map does neither contain the `init` field of Contract Deployment
Expand All @@ -112,17 +109,6 @@ pub(crate) fn generate_jumpdest_table<'a>(
})
.collect();

// REVIEW: will be removed before merge
trace!(
"Transaction: {} is a {}.",
tx.hash,
if tx.to.is_some() {
"message call"
} else {
"contract creation"
}
);

let entrypoint_code_hash: H256 = match tx.to {
Some(to_address) if is_precompile(to_address.compat()) => return Ok(jumpdest_table),
Some(to_address) if callee_addr_to_code_hash.contains_key(&to_address).not() => {
Expand All @@ -147,7 +133,7 @@ pub(crate) fn generate_jumpdest_table<'a>(
next_ctx_available += 1;

let mut stuctlog_iter = structlog.iter().enumerate().peekable();
while let Some((step, entry)) = stuctlog_iter.next() {
while let Some((_step, entry)) = stuctlog_iter.next() {
let op = entry.op.as_str();
let curr_depth: usize = entry.depth.try_into().unwrap();

Expand All @@ -163,22 +149,6 @@ pub(crate) fn generate_jumpdest_table<'a>(
);
let (code_hash, ctx) = call_stack.last().unwrap();

// REVIEW: will be removed before merge
trace!(
step,
curr_depth,
tx_hash = ?tx.hash,
?code_hash,
ctx,
next_ctx_available,
pc = entry.pc,
pc_hex = format!("{:08x?}", entry.pc),
gas = entry.gas,
gas_cost = entry.gas_cost,
op,
?entry,
);

match op {
"CALL" | "CALLCODE" | "DELEGATECALL" | "STATICCALL" => {
prev_jump = None;
Expand All @@ -191,7 +161,6 @@ pub(crate) fn generate_jumpdest_table<'a>(
let operands_used = 2;

if evm_stack.len() < operands_used {
trace!( "Opcode {op} expected {operands_used} operands at the EVM stack, but only {} were found.", evm_stack.len());
// Note for future debugging: There may exist edge cases, where the call
// context has been incremented before the call op fails. This should be
// accounted for before this and the following `continue`. The details are
Expand All @@ -209,21 +178,6 @@ pub(crate) fn generate_jumpdest_table<'a>(
call_stack.push((next_code_hash, next_ctx_available));
};

if is_precompile(callee_address.compat()) {
trace!("Called precompile at address {}.", &callee_address);
};

if callee_addr_to_code_hash.contains_key(&callee_address).not()
&& is_precompile(callee_address.compat()).not()
{
// This case happens if calling an EOA. This is described
// under opcode `STOP`: https://www.evm.codes/#00?fork=cancun
trace!(
"Callee address {} has no associated `code_hash`.",
&callee_address
);
}

if let Some((_next_step, next_entry)) = stuctlog_iter.peek() {
let next_depth: usize = next_entry.depth.try_into().unwrap();
if next_depth < curr_depth {
Expand Down Expand Up @@ -252,7 +206,6 @@ pub(crate) fn generate_jumpdest_table<'a>(
let evm_stack: Vec<_> = entry.stack.as_ref().unwrap().iter().rev().collect();
let operands = 1;
if evm_stack.len() < operands {
trace!( "Opcode {op} expected {operands} operands at the EVM stack, but only {} were found.", evm_stack.len() );
continue;
}
let [jump_target, ..] = evm_stack[..] else {
Expand All @@ -268,7 +221,6 @@ pub(crate) fn generate_jumpdest_table<'a>(
let evm_stack: Vec<_> = entry.stack.as_ref().unwrap().iter().rev().collect();
let operands = 2;
if evm_stack.len() < operands {
trace!( "Opcode {op} expected {operands} operands at the EVM stack, but only {} were found.", evm_stack.len());
continue;
};

Expand All @@ -290,20 +242,11 @@ pub(crate) fn generate_jumpdest_table<'a>(
prev_jump = None;

if jumped_here.not() {
trace!(
"{op}: JUMPDESTs at offset {} was reached through fall-through.",
entry.pc
);
continue;
}

let jumpdest_offset = TryInto::<usize>::try_into(entry.pc);
if jumpdest_offset.is_err() {
trace!(
"{op}: Could not cast offset {} to usize {}.",
entry.pc,
usize::MAX
);
continue;
}
ensure!(jumpdest_offset.unwrap() < 24576);
Expand Down

0 comments on commit d67911e

Please sign in to comment.