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

Set rustfmt max_width to 100 #311

Merged
merged 1 commit into from
Jan 28, 2022
Merged

Set rustfmt max_width to 100 #311

merged 1 commit into from
Jan 28, 2022

Conversation

ed255
Copy link
Member

@ed255 ed255 commented Jan 28, 2022

As discussed, we agreed to increase the max_width set in the rustfmt.toml to 100 in order to improve the code readability considering current standards (this is the default used by rustfmt)

Apart from changing the rustfmt.toml I've reformatted all code to pass the CI checks using:

cargo check --all-features # required to generate `circuit-benchmarks/src/bench_params.rs`
cargo fmt --all

For opened PRs I'm sure that after this is merged they'll find conflicts. Maybe the easiest way for them to resolve the conflicts will be to first update the rustfmt.toml (to set max_width = 100) and run cargo fmt --all in their branch, commit, and then merge main into the branch.

NOTE: I think the easiest way to verify this PR is to do the same change on a local branch and compare it with this branch and see that there are no differences.

@github-actions github-actions bot added crate-bus-mapping Issues related to the bus-mapping workspace member crate-keccak Issues related to the keccak workspace member T-opcode Type: opcode-related and focused PR/Issue crate-zkevm-circuits Issues related to the zkevm-circuits workspace member labels Jan 28, 2022
Copy link
Contributor

@CPerezz CPerezz left a comment

Choose a reason for hiding this comment

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

LGTM.

Just one question: Should we check whether the CI needs also to be changed to consume rustfmt.toml desired settings from the file?

As it does not make sense that the rustfmt check keeps failing.

@0xmountaintop
Copy link
Collaborator

0xmountaintop commented Jan 28, 2022

LGTM.

Just one question: Should we check whether the CI needs also to be changed to consume rustfmt.toml desired settings from the file?

As it does not make sense that the rustfmt check keeps failing.

looks like it's consuming it on CI (the suggestions are wider)
image

@ed255 ed255 force-pushed the feature/rustfmt-width-100 branch from 3b0166b to 12a0830 Compare January 28, 2022 15:38
@ed255
Copy link
Member Author

ed255 commented Jan 28, 2022

I think the issue was that I ran cargo fmt --all without doing first cargo check --all-features, and that resulted in my zkevm-circuits directory not having the file circuit-benchmarks/src/bench_params.rs, so the bench_params module in circuit-benchmarks was not being found by cargo fmt and that caused it to not complete formatting everything:

$ cargo fmt --all
Error writing files: failed to resolve mod `bench_params`: /home/dev/git/zkevm/zkevm-circuits/circuit-benchmarks/src does not exist

Running cargo check --all-features has generated that file, and afterwards cargo fmt has run successfully without skipping any file. Now the CI passes :)

@CPerezz
Copy link
Contributor

CPerezz commented Jan 28, 2022

@ed255 can we merge and check the rest of PR's statuses?

@ed255
Copy link
Member Author

ed255 commented Jan 28, 2022

@ed255 can we merge and check the rest of PR's statuses?

Yes! I'll merge now

@ed255 ed255 merged commit d0c04af into main Jan 28, 2022
@ed255
Copy link
Member Author

ed255 commented Jan 28, 2022

A note for currently open PRs:
Most likely you'll get conflicts from main because many lines have changed due to this PR (but it's just rearrangements). Resolving the conflicts manually should be easy, but I think that if you follow this approach to update the branch it will be much less work:

  1. From your PR branch edit rustfmt.toml and set max_width to 100
  2. Do cargo check --all-features and cargo fmt --all
  3. git add . && git commit -m "Reformat code with 100 chars width"
  4. git fetch origin && git merge main
    This way, when you bring your branch up to date with main, you already have the code at 100 lines and thus reduce a lot the number of conflicts

This will affect #170 #268 #292 #297 #298 #301 #302 #303 #307 #310

@barryWhiteHat barryWhiteHat added benchmarks: ALL Triggers a long running prover benchmark and removed benchmarks: ALL Triggers a long running prover benchmark labels Jan 31, 2022
@ed255 ed255 deleted the feature/rustfmt-width-100 branch March 23, 2022 12:27
zemse pushed a commit to zemse/zkevm-circuits that referenced this pull request Mar 22, 2023
…-scaling-explorations#311)

* Add a `LtGadget` to avoid mock prover assigning a value which is greater than 255.

* Revert "Add a `LtGadget` to avoid mock prover assigning a value which is greater than 255."

This reverts commit 537748b.

* Assign InvalidOpcode to `exec_step.error` directly. Since it has been done in `get_step_err`.

* Delete `internal` test cases since it has no effects for invalid opcode error.

* Delete mapping `OpcodeId::INVALID` to dummy function in `fn_gen_associated_ops`. And Move `fn_gen_associated_ops` to the end of `gen_associated_ops` (after `get_step_err`).

* Revert "Delete `internal` test cases since it has no effects for invalid opcode error."

This reverts commit 759ed13.

* Fix to only keep one call data offset and length pair for internal test.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
crate-bus-mapping Issues related to the bus-mapping workspace member crate-keccak Issues related to the keccak workspace member crate-zkevm-circuits Issues related to the zkevm-circuits workspace member T-opcode Type: opcode-related and focused PR/Issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants