-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Add Math.modExp and a Panic library
#3298
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
Changes from 1 commit
91e39eb
712a0f3
77f33ea
4683f26
7489ce4
d576641
0d78d29
5d99ed8
acb16f2
d7e81cf
85187dd
d458765
01badeb
a1c1439
d81d69d
6e8cced
fd7b8de
26a036e
4ba0a29
988c950
c08ac50
98f7994
f634aab
66a0c1f
eecd818
1583160
19ead8e
8cf355f
113e85e
4e1cf0d
6d7c154
84b285d
9e73f46
76c9afa
1ff0776
f84b1b6
fe32a38
4accc2e
cfd80e9
526d6b9
3718090
cd2f2e9
104002e
d149ea6
05aa60e
f352681
32ea4bb
2e962c8
275c959
24cd52a
50374a1
ee91836
d13e52d
969e259
e64c3f9
06220be
9137bae
81e8ba0
2b72050
2fc20d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,8 +5,8 @@ pragma solidity ^0.8.20; | |
| /** | ||
| * @dev Helper library for emitting standardized panic codes. | ||
| */ | ||
| // slither-disable-next-line unused-state | ||
| library Panic { | ||
| // slither-disable-start unused-state-variable | ||
| uint256 internal constant ASSERTION_ERROR = 0x1; | ||
| uint256 internal constant ARITHMETIC_UNDER_OR_OVERFLOW = 0x11; | ||
| uint256 internal constant DIVISION_BY_ZERO = 0x12; | ||
|
|
@@ -17,8 +17,6 @@ library Panic { | |
| uint256 internal constant TOO_MUCH_MEMORY_ALLOCATED = 0x41; | ||
| uint256 internal constant ZERO_INITIALIZED_VARIABLE = 0x51; | ||
|
|
||
| // slither-disable-end unused-state-variable | ||
|
|
||
| function panic(uint256 code) internal pure { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right now anyone can call I'm not sure how frequently Solidity adds (or changes) the panic codes, but imagine the following situation:
Wouldn't it be bad that the same revert code has different meanings?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alternatively we can generate this library procedurally wth the codes, such that users can do:
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not too worried about users emitting random panic code ... but I'm not fundamentally opposed to making We would have to make them CamelCase though.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The thing, if new panic code are ever added, the current version would allow users to use them without us having to do a release.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Agree with this syntax.
Right, good point. If the goal is to provide a workaround then I would be fine if we release the I know this is kind of the same thing but I feel the design of the library API is more friendly if we keep each panic code function and also the custom
Would you agree with this?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The linter rules are not ok with that, and I think we should follow them:
I'm not sure that is a good point. When testing panic code with hardhat you do you don't to
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the current version is simple and effective. It's targetting advanced users anyway.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Fair
We should document the function then. Currently it allows panicking with anything it I think it needs some usage instructions in both the contracts NatSpec and the |
||
| /// @solidity memory-safe-assembly | ||
| assembly { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.