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

Add mypy#132

Merged
han0110 merged 4 commits into
privacy-ethereum:masterfrom
han0110:feature/mypy
Mar 11, 2022
Merged

Add mypy#132
han0110 merged 4 commits into
privacy-ethereum:masterfrom
han0110:feature/mypy

Conversation

@han0110
Copy link
Copy Markdown
Contributor

@han0110 han0110 commented Feb 25, 2022

This PR aims to add mypy for more strict type checking.

Following @ed255's suggestion in this comment, it introduces an interface Expression providing function expr which returns a FQ. In this way, we are always comparing number in field, and can avoid unsupported types comparing or integer underflow issues.

It's built upon #110 because #110 removes some unused things, then we don't bother to fix typing of them.

Co-authored-by: @ChihChengLiang
Co-authored-by: @ed255

Copy link
Copy Markdown
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. Epic PR Han, that's a lot of improvements in typing and readabilities.

Comment thread src/zkevm_specs/evm/execution/storage.py Outdated
Comment thread src/zkevm_specs/evm/execution/storage.py Outdated
@han0110 han0110 force-pushed the feature/mypy branch 3 times, most recently from 2a7f845 to 7c5bec8 Compare February 28, 2022 04:49
@ed255
Copy link
Copy Markdown
Contributor

ed255 commented Mar 1, 2022

I plan on reviewing this once #110 is merged :)

Copy link
Copy Markdown
Contributor

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

This PR is a great improvement in readability and usability! 🎊
Thanks @han0110 and @ChihChengLiang for working on this!

self.message = f"Lookup {table_name} is ambiguous on inputs {inputs}, ${len(matched_rows)} matched rows found: {matched_rows}"


class TableRow:
Copy link
Copy Markdown
Contributor

@ed255 ed255 Mar 4, 2022

Choose a reason for hiding this comment

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

These new types to express table rows are very welcome! They improve readability a lot :)

Comment thread tests/evm/test_add.py
(10, RW.Read, RWTableTag.Stack, 1, 1023, 0, b, 0, 0, 0),
(11, RW.Write, RWTableTag.Stack, 1, 1023, 0, c, 0, 0, 0),
]
RWDictionary(9)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks very nice! I really like this RWDictionary class, makes tests more readable and less error prone!

Copy link
Copy Markdown
Collaborator

@icemelon icemelon left a comment

Choose a reason for hiding this comment

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

just a nitpick, otherwise this PR looks great

Comment thread src/zkevm_specs/util/arithmetic.py Outdated
@icemelon
Copy link
Copy Markdown
Collaborator

icemelon commented Mar 9, 2022

Could we prioritize the merge of this PR first as it's quite huge and will conflict with many open PRs? And it also introduces useful tools like RWDictionary

@han0110 han0110 merged commit 9ab5681 into privacy-ethereum:master Mar 11, 2022
@han0110 han0110 deleted the feature/mypy branch March 11, 2022 14:03
@0xmountaintop 0xmountaintop mentioned this pull request Mar 17, 2022
@han0110 han0110 mentioned this pull request Mar 21, 2022
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.

4 participants