-
Notifications
You must be signed in to change notification settings - Fork 153
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
feat(contracts) - add custom errors #764
Conversation
Just want to get a better grip on the benefits. I'm asking purely to learn:
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the main problem this PR wants to address is 'Contracts inheriting the MACI contracts could fail to deploy due to hitting contract size limit,' as mentioned in #761. But we shouldn't compromise on the clarity of error messages. One middle-ground solution could be to use concise error codes in the contract and provide inline comments for additional context. Another approach would be to maintain an external error code table for comprehensive explanations, making it easier for debugging without affecting contract size.
vkRegistry.owner() == owner(), | ||
"MACI: VkRegistry owner incorrectly set" | ||
); | ||
if (pollFactory.owner() != address(this)) revert WrongPollOwner(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The term 'WrongPollOwner' is ambiguous and could imply various issues—whether the owner is not set, incorrectly set, or unauthorized. This lack of specificity contrasts with the original message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in Solidity if a value is not set it would be set as the default value -> in the address case it would be address(0). Now let's evaluate: address(0) != address(this) -> this would evaluate as false -> address zero (which is not set) is the wrong poll owner.
Given the contracts inherit the Ownable library, once a contract is deployed, the contract owner becomes the address deploying -> it could only be "not set" (which really is set to address(0)) if they were to renounce ownership -> hence stil incorrect owner.
This table compares the deployed sizes and shows how much they have been reduced by introducing custom errors:
|
279cebc
to
842ce1a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for taking the time to go through the comments and making those adjustments. LGTM!
842ce1a
to
0f446ee
Compare
fix #761
fix #774