Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Cycle count in logs for interpreter #77

Merged
merged 6 commits into from
Mar 4, 2024
Merged

Conversation

Nashtare
Copy link
Collaborator

@Nashtare Nashtare commented Mar 2, 2024

Tiny other fix from #56.
Running CPU simulation outputs the correct total CPU cycles count at the end, but using Debug or Trace levels would display always Cycle 0 with current main when going through the execution.
The issue was that we were still using GenerationState for log_kernel_instruction instead of the new State trait.

It also hides the final unpadded length print behind a #[cfg(not(test))] flag, as to not get the CI logs too verbose (it's getting spammed currently).

@Nashtare Nashtare added bug Something isn't working crate: evm_arithmetization Anything related to the evm_arithmetization crate. labels Mar 2, 2024
@Nashtare Nashtare self-assigned this Mar 2, 2024
Comment on lines -451 to -482
/// Increments the `gas_used` register by a value `n`.
fn incr_gas(&mut self, n: u64) {
self.registers.gas_used += n;
}

/// Increments the `program_counter` register by a value `n`.
fn incr_pc(&mut self, n: usize) {
self.registers.program_counter += n;
}

/// Returns a `State`'s registers.
fn get_registers(&self) -> RegistersState {
self.registers
}

/// Returns a `State`'s mutable registers.
fn get_mut_registers(&mut self) -> &mut RegistersState {
&mut self.registers
}

/// Returns the value stored at address `address` in a `State`.
fn get_from_memory(&mut self, address: MemoryAddress) -> U256 {
self.memory.get_with_init(address)
}

/// Returns a mutable `GenerationState` from a `State`.
fn get_generation_state(&self) -> &GenerationState<F> {
self
}

fn get_mut_generation_state(&mut self) -> &mut GenerationState<F> {
self
}

/// Returns the value of a `State`'s clock.
fn get_clock(&self) -> usize {
self.traces.clock()
}

/// Rolls back a `State`.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these methods are from the State trait, so re-documenting here is useless.

@Nashtare Nashtare requested a review from LindaGuiga March 4, 2024 00:49
Copy link
Contributor

@LindaGuiga LindaGuiga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@Nashtare Nashtare merged commit ac1998c into main Mar 4, 2024
5 checks passed
@Nashtare Nashtare deleted the cycle_output_interpreter branch March 4, 2024 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crate: evm_arithmetization Anything related to the evm_arithmetization crate.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants