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

state circuit update part1: change RwTable according to latest spec; finish stack/storage constraints #380

Merged

Conversation

lispc
Copy link
Collaborator

@lispc lispc commented Mar 7, 2022

resolving issue: #356

The reason why I submit this WIP PR now is that RwTable is updated according to the latest spec here. Another key column is added, so the overall keys become: tag,key1,key2,key3,key4.

If we can merge this PR early, we may encounter less conflicts on RwTable. So i think it is better to split the whole state circuit refactor PR into several smaller ones, merge them one by one periodically

@github-actions github-actions bot added T-opcode Type: opcode-related and focused PR/Issue crate-zkevm-circuits Issues related to the zkevm-circuits workspace member labels Mar 7, 2022
@lispc lispc changed the title state circuit update part1: update RwTable according to latest spec; finish stack/storage constraints state circuit update part1: change RwTable according to latest spec; finish stack/storage constraints Mar 7, 2022
@lispc
Copy link
Collaborator Author

lispc commented Mar 7, 2022

@ed255 @miha-stopar

Copy link
Collaborator

@miha-stopar miha-stopar left a comment

Choose a reason for hiding this comment

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

I like it very much! Much cleaner than my implementation.

Only one question - the constraints for the address monotonicity are to be added, right? (referring to the disabled test)

@lispc
Copy link
Collaborator Author

lispc commented Mar 8, 2022

I like it very much! Much cleaner than my implementation.

Only one question - the constraints for the address monotonicity are to be added, right? (referring to the disabled test)

yes. Old implementation uses lookup, but we need finally use range check. This modification needs some work. So I disable it temporarily

@miha-stopar
Copy link
Collaborator

I like it very much! Much cleaner than my implementation.
Only one question - the constraints for the address monotonicity are to be added, right? (referring to the disabled test)

yes. Old implementation uses lookup, but we need finally use range check. This modification needs some work. So I disable it temporarily

Cool, thanks!

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.

This looks very good! Thanks for the nice work :)

I've added some comments and questions. Maybe you're planning to address them in the next PR, that's totally OK by me! But if that's the case I would just ask if you can add some small comments stating the missing tasks with TODO.

zkevm-circuits/src/state_circuit/state.rs Show resolved Hide resolved
zkevm-circuits/src/state_circuit/state.rs Show resolved Hide resolved
zkevm-circuits/src/state_circuit/state.rs Show resolved Hide resolved
zkevm-circuits/src/state_circuit/state.rs Show resolved Hide resolved

for (i, diff_is_zero_chip) in diff_is_zero_chips.iter().enumerate() {
let (value, diff) = match i {
// FIXME: find a better way here
Copy link
Member

Choose a reason for hiding this comment

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

I think this is good enough :)
The only think that would come to my mind to improve this would be to change RwRow to have a field keys: [F, 5].

region.assign_advice(|| "rw counter", self.rw_counter, offset, || Ok(rw_counter))?;
region.assign_advice(|| "value", self.value, offset, || Ok(value))?;
region.assign_advice(|| "is_write", self.is_write, offset, || Ok(is_write))?;

Copy link
Member

Choose a reason for hiding this comment

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

I noticed that the following values are not assigned:

  • value_prev
  • aux1
  • aux2

Why is that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, I will add "aux1" and "aux2"! While I think value_prev has been removed already in the spec?

Copy link
Member

Choose a reason for hiding this comment

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

ah that's right, value_prev is no longer in the state circuit spec.

zkevm-circuits/src/state_circuit/state.rs Show resolved Hide resolved
@lispc
Copy link
Collaborator Author

lispc commented Mar 11, 2022

@ed255 Hi Edu, I addressed the comments above~ You can have a look. Thanks!

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! Thanks for addressing my comments :)

region.assign_advice(|| "rw counter", self.rw_counter, offset, || Ok(rw_counter))?;
region.assign_advice(|| "value", self.value, offset, || Ok(value))?;
region.assign_advice(|| "is_write", self.is_write, offset, || Ok(is_write))?;

Copy link
Member

Choose a reason for hiding this comment

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

ah that's right, value_prev is no longer in the state circuit spec.

@ed255 ed255 merged commit eaa4184 into privacy-scaling-explorations:main Mar 11, 2022
zemse pushed a commit to zemse/zkevm-circuits that referenced this pull request Mar 22, 2023
…acy-scaling-explorations#380)

* Constrain `CALLDATALOAD` stack push result must be 0 if stack pop offset is Uint64 overflow.

* Fix `valid_bytes` to a const generic parameter in `WordRangeGadget`.

* Refactor memory `copy_from` in bus-mapping.

* Fix a mistake in bus-mapping `CALLDATACOPY`.

* Refactor to use `WordByteCapGadget`.

* Fix lint.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

None yet

4 participants