Skip to content
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

audit: Function Parameter Location Optimizations #179

Closed
Orland0x opened this issue Jun 13, 2023 · 0 comments · Fixed by #199
Closed

audit: Function Parameter Location Optimizations #179

Orland0x opened this issue Jun 13, 2023 · 0 comments · Fixed by #199
Assignees

Comments

@Orland0x
Copy link
Contributor

Many functions take parameters in memory instead of in calldata. If the parameters don't need to be modified, it is more efficient not to copy them to memory unless absolutely necessary. In general, copying of entire structs should be avoided when possible.
This improvement can be made in the following places: #. All of the Space contract's setter functions, its initialize function and _getCumulativePower. (Note that the latter would also require an assertNoDuplicateIndices implementation with a calldata list). #. The _assertProposalExists takes a Proposal memory as a parameter. However, in the execute and cancel functions it is passed a Proposal storage variable. Thus, the entire struct will be copied into memory only to check a single field's value. #. The bytesToAddress function in the CompVotingStrategy and OZVotingStrategy could take a bytes calldata parameter instead of a bytes memory. #. The various _verify functions in the SignatureVerifier could take bytes calldata as a parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant