Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Move stats to bin #1407

Merged
merged 14 commits into from
May 16, 2023
Merged

Move stats to bin #1407

merged 14 commits into from
May 16, 2023

Conversation

ChihChengLiang
Copy link
Collaborator

Description

We have 4 utility commands that show us statistics of different circuits. Currently, these features were compiled with the tests, causing dependency and feature flags management troubles. The commands also cause confusion with the ignored test flags.

We can enjoy many benefits if we keep these commands in binary executables.

  • We can compile them on demand. We remove compilation overheads for the main components and tests.
  • Stats commands are confined in the bin directory, so we don't have confusing testing code.

Issue Link

It was #1246. After exploring, I found room for improving the status quo.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Contents

  • Move the underlying logics of make stats_state_circuit, make stats_evm_circuit, make stats_copy_circuit, and make evm_exec_steps_occupancy to bin directory.
  • Add a feature flag, stats for these specific tools.
  • Remove DisplayTable and replace all its use with cli-table's feature. This has the benefit that the line of codes in the codebase reflects more on the core zkevm functionality. After we used cli-table, the table also rendered differently, see images below.
  • Move cli-table from dev-dependency to dependency, but as an optional dependency.
  • Remove dead dependency subtle and criterion

After:
Screenshot 2023-05-14 at 3 26 43 PM
Before:
Screenshot 2023-05-14 at 3 27 53 PM

Rationale

  • Some undesirable results were introduced.
    • We left the Instrument struct unchanged. The Instrument is buried deep in the ExecutionConfig. We intend to deal with it in future PRs to keep the diff of this one slim.
    • We changed some visibilities of structs and functions in evm circuits from pub(crate) to pub

How Has This Been Tested?

Manual run make stats_state_circuit, make stats_evm_circuit, make stats_copy_circuit, and make evm_exec_steps_occupancy and see if they work.

@github-actions github-actions bot added the crate-zkevm-circuits Issues related to the zkevm-circuits workspace member label May 14, 2023
Copy link
Collaborator

@han0110 han0110 left a comment

Choose a reason for hiding this comment

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

LGTM! Nice refactor!

Copy link
Member

@ed255 ed255 left a comment

Choose a reason for hiding this comment

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

LGTM! The stats functions look cleaner now. I wasn't expecting such a big code reduction from this!

@ChihChengLiang ChihChengLiang added this pull request to the merge queue May 16, 2023
Merged via the queue into main with commit ead0b3d May 16, 2023
ChihChengLiang added a commit that referenced this pull request May 16, 2023
### Description

We remove `#![allow(dead_code)]` everywhere in the codebases other than
`zkevm-circuits`.

This PR should be merged after #1407 

### Issue Link

No issue yet

### Type of change

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

### Contents

- Removed `#![allow(dead_code)]` everywhere other than `zkevm-circuits`.
- Make test utility functions like `Block::get_test_degree` and
`Sha3CodeGen` public functions so that they don't cause `cargo build -p
zkevm-circuits` to fail. This might come with the cost of extra
compilation time.
- Refactor `gen_sha3_code` into `Sha3CodeGen` so that we don't have to
import `MemoryKind` to use it.
@ChihChengLiang ChihChengLiang deleted the move-stats-to-bin branch May 17, 2023 08:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
crate-zkevm-circuits Issues related to the zkevm-circuits workspace member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants