forked from privacy-scaling-explorations/zkevm-circuits
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix-bufferreader: constrain the "in-bound" selectors vs the addresses (…
…privacy-scaling-explorations#1485) ### Description In the BufferReaderGadget, there are two conflicting mechanisms that enforces the zero padding, one based on `selectors`, and one based on `bound_dist`. This causes the issue privacy-scaling-explorations#1484. This PR fixes this and improves performance at the same time. ### Issue Link privacy-scaling-explorations#1484 ### 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 - Remove the columns `bound_dist` and everything related to it. - Repurpose the unused `selectors` and add constraints to it. - The buffer length is taken as the sum of selectors, and compared to the length implied by the start and end addresses. - The cases where `start < end` and `end <= start` are supported explicitly. - The length is capped between 0 and the max buffer size using the existing MinMaxGadget. A single MinMaxGadget is used thanks to a `select`. - Remove the unused methods `has_data` and `num_bytes`. ### Rationale The simplest fix would be to remove the `selectors` and keep the `bound_dist` mechanism. However, this PR does a more efficient way. Indeed, the existing logic on the selectors is simple and cheap, while the other is costly because it compares every index to the addresses. ### How Has This Been Tested? `cargo test --package zkevm-circuits --features test -- evm_circuit::execution::calldataload` --------- Co-authored-by: Aurélien Nicolas <[email protected]> Co-authored-by: Rohit Narurkar <[email protected]>
- Loading branch information
1 parent
ee93a18
commit 6cd8025
Showing
2 changed files
with
56 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters