-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
TimelockController
contract's constructor takes input parameters as memory
instead of calldata
#4216
Comments
From @barakman, adding more information:
|
TimelockController
contract's constructor takes input parameters as memory
instead of calldata
@ernestognw I'd be interested in opening up a PR to implement this change! In addition to setting the contract's constructor input parameters to
These are pretty low-hanging fruit and won't pose huge change to, or a complete overhaul of, |
Hey @0xIchigo, you can go ahead and create a PR for solving the issue this thread is about: However, this is my perspective on each one of them:
I don't see reasons for not doing these and it's not breaking so it should be fine.
These are a little bit risky since they involve readability, I think we'd overall prefer not to do them since:
Correct me if I'm wrong on number 2 but both reasons together make a good reason to make a discussion first.
We're already working on a major migration to custom errors. You can see the discussion in #2839. The TLDR is that we proposed EIP (6093) for standard tokens and we'll use the same rationale to design the custom errors for the whole library. A big nuance we're currently facing is deciding how many parameters to add to a custom error so that they're useful enough without sacrificing the optimization itself. Consider that a change in parameters to a custom error could be considered a breaking change, so once Contracts 5.0 is released, we may be locked. We'd appreciate feedback (if any) on how to design the errors. The discussion for that is here. Will wait for input from @frangio on this before giving you the green light. Thank you for your willingness to contribute! |
Hey @ernestognw, I appreciate your quick response! I'll go ahead and create a PR for solving the With respect to incrementing the variable With respect to readability, the unchecked block can be placed at the bottom of the for loop instead of being placed inline with the initialization and condition. Instead of having a hard to read for loop header, the complexity is abstracted away with the unchecked block at bottom of the loop. I'd argue that a reduction of roughly 28.7% - 32.2% for iterations <= 100 would warrant this optimization, although I see how this is not 100% ideal in terms of readability since you'd be splitting up the loop's initialization, condition, and iteration. Regardless, I am a firm believer that any optimizations, irrespective of their size, that can be easily implemented without posing too great of an impact to the contract's structure, functionality, and adoption should be implemented. I'll checkout the discussion regarding EIP 6093, and see if I have any feedback on designing the errors, thanks! |
Hey @ernestognw, sorry for the double ping but I just realized that we cannot optimize the If possible, I'd still like to go ahead with creating a PR to optimize the for loops found within |
FYI, the length of dynamic arrays is bounded by So an overflow in the loop counter could not occur here even theoretically, regardless of the block gas limit. |
Closing as explained above constructors can't have calldata arguments. For other optimizations please open an issue sharing benchmarks that demonstrate an improvement. |
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/governance/TimelockController.sol#L81
Reason:
Replacing
memory
bycalldata
The text was updated successfully, but these errors were encountered: