use crate::tracing::*;
pub use crate::zkevm_opcode_defs::utils::*;
use crate::zkevm_opcode_defs::{decoding::VmEncodingMode, ethereum_types::U256};
use zk_evm_abstractions::vm::Memory;
use lazy_static::lazy_static;
lazy_static! {
pub static ref U256_TO_ADDRESS_MASK: U256 = U256::MAX >> (256 - 160);
}
pub fn contract_bytecode_to_words(code: &[[u8; 32]]) -> Vec<U256> {
code.iter().map(|el| U256::from_big_endian(el)).collect()
}
pub fn address_to_u256(address: &crate::Address) -> U256 {
let mut buffer = [0u8; 32];
buffer[12..].copy_from_slice(&address.as_fixed_bytes()[..]);
U256::from_big_endian(&buffer)
}
pub fn u256_to_address_unchecked(integer: &U256) -> crate::Address {
let mut buffer = [0u8; 32];
integer.to_big_endian(&mut buffer);
crate::Address::from_slice(&buffer[12..32])
}
#[derive(Debug, Default, Clone, Copy)]
pub struct GenericNoopTracer<M: Memory> {
_marker: std::marker::PhantomData<M>,
}
impl<M: Memory> GenericNoopTracer<M> {
pub fn new() -> Self {
Self {
_marker: std::marker::PhantomData,
}
}
}
impl<M: Memory, const N: usize, E: VmEncodingMode<N>> Tracer<N, E> for GenericNoopTracer<M> {
type SupportedMemory = M;
fn before_decoding(
&mut self,
_state: VmLocalStateData<'_, N, E>,
_memory: &Self::SupportedMemory,
) {
}
fn after_decoding(
&mut self,
_state: VmLocalStateData<'_, N, E>,
_data: AfterDecodingData<N, E>,
_memory: &Self::SupportedMemory,
) {
}
fn before_execution(
&mut self,
_state: VmLocalStateData<'_, N, E>,
_data: BeforeExecutionData<N, E>,
_memory: &Self::SupportedMemory,
) {
}
fn after_execution(
&mut self,
_state: VmLocalStateData<'_, N, E>,
_data: AfterExecutionData<N, E>,
_memory: &Self::SupportedMemory,
) {
}
}