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

Specs for opcode DIV and MOD #149

Merged

Conversation

icemelon
Copy link
Collaborator

No description provided.

Copy link
Member

@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.

In the latest version of master, Instruction just has the following two methods for rlc_to_fq:

def rlc_to_fq_unchecked(self, rlc: RLC, n_bytes: int) -> FQ:
        rlc_le_bytes = self.rlc_to_le_bytes(rlc)
        return self.bytes_to_fq(rlc_le_bytes[:n_bytes]), self.is_zero(
            self.sum(rlc_le_bytes[n_bytes:])
        )

    def rlc_to_fq_exact(self, rlc: RLC, n_bytes: int) -> FQ:
        rlc_le_bytes = self.rlc_to_le_bytes(rlc)

        if sum(rlc_le_bytes[n_bytes:]) > 0:
            raise ConstraintUnsatFailure(f"Value {rlc} has too many bytes to fit {n_bytes} bytes")

        return self.bytes_to_fq(rlc_le_bytes[:n_bytes])

I guess that the branch is not up-to-date or similar. Please update the method name. See this

Aside from that, I'll wait to review the rest until my concern over conditional copies ending up on PermutationErrors is resolved. As it could lead to some big changes in the spec in case I'm right (I would like to not to be TBH).

specs/opcode/02MUL_04DIV_06MOD.md Outdated Show resolved Hide resolved
src/zkevm_specs/evm/execution/__init__.py Outdated Show resolved Hide resolved
src/zkevm_specs/evm/execution/__init__.py Outdated Show resolved Hide resolved
src/zkevm_specs/evm/execution/mul.py Outdated Show resolved Hide resolved
src/zkevm_specs/evm/execution/mul.py Outdated Show resolved Hide resolved
Copy link
Member

@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.

For what refers to the spec. Looks good TBH. I clarified my concerns above with Han and Edu.

The only part I think it's sill not ok from this PR is that seems to be off-sync with master or the rebase removed a lot of stuff which is still used in master (and it's not the purpose of the PR).

src/zkevm_specs/evm/execution/mul.py Outdated Show resolved Hide resolved
src/zkevm_specs/evm/instruction.py Outdated Show resolved Hide resolved
src/zkevm_specs/evm/instruction.py Show resolved Hide resolved
Copy link
Member

@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!! Thanks for the PR and the great work!

If you can add a new line to the files that lack it at the end would be awesome 😄

@icemelon
Copy link
Collaborator Author

@ChihChengLiang @han0110 The mdformat complains the latex equations in the markdown doc. Do you guys have any idea how to bypass certain checks in the mdformat or maybe disable it for this file?

@ChihChengLiang
Copy link
Collaborator

@icemelon It seems mdformat doesn't have a plan to support the ignore feature yet hukkin/mdformat#53.
Let me create a PR to remove the CI check.

@icemelon
Copy link
Collaborator Author

@ChihChengLiang Could you help review this PR?

@CPerezz
Copy link
Member

CPerezz commented Mar 29, 2022

@ChihChengLiang Could you help review this PR?

He'll be back on Wed.

Maybe @ed255 can check this.

@ChihChengLiang
Copy link
Collaborator

Sorry for my absence. I am reviewing this now.

Copy link
Collaborator

@ChihChengLiang ChihChengLiang left a comment

Choose a reason for hiding this comment

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

Find an issue in the compare_word. Maybe the testing bug is related?

src/zkevm_specs/evm/execution/mul_div_mod.py Show resolved Hide resolved
src/zkevm_specs/evm/instruction.py Outdated Show resolved Hide resolved
src/zkevm_specs/evm/instruction.py Show resolved Hide resolved
Copy link
Collaborator

@ChihChengLiang ChihChengLiang left a comment

Choose a reason for hiding this comment

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

LGTM, mergeable after a rebase

@icemelon
Copy link
Collaborator Author

icemelon commented Apr 1, 2022

@ChihChengLiang Rebased now

@ChihChengLiang ChihChengLiang merged commit a6b8a20 into privacy-scaling-explorations:master Apr 1, 2022
@ChihChengLiang
Copy link
Collaborator

Thank you Haichen for the PR!

@icemelon icemelon deleted the feat/div_mod branch April 1, 2022 06:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants