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 #199

Merged
merged 8 commits into from
Jun 15, 2023

Conversation

Orland0x
Copy link
Contributor

@Orland0x Orland0x commented Jun 13, 2023

closes #179

@Orland0x Orland0x changed the title fix: use calldata when possible audit: use calldata when possible Jun 13, 2023
Copy link
Collaborator

@pscott pscott left a comment

Choose a reason for hiding this comment

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

They mention _assertProposalExists, assertNoDuplicateIndices, bytesToAddress, _verify* functions. Any reason we don't address those?

@Orland0x
Copy link
Contributor Author

Orland0x commented Jun 13, 2023

They mention _assertProposalExists, assertNoDuplicateIndices, bytesToAddress, _verify* functions. Any reason we don't address those?

I modified `assertNoDuplicateIndices.

I changed _verifyVoteSig but couldnt do the same for _verifyProposeSig and _verifyUpdateProposalSig as I ran into stack too deep errors when using calldata, so decided to leave as memory considering those operations are not super gas critical anyway.

Not sure whether it is actually possible to use calldata in bytesToAddress, hence why the original lib i took it from didnt.

we call _assertProposalExists with a Propose storage variable in execute and cancel, so cannot prevent it being copied to memory. We could remove the function call and check proposal.startTimestamp == 0 directly but keeping the _assertProposalExists abstraction is more readable imo. thoughts?

@Orland0x Orland0x changed the title audit: use calldata when possible audit: Function Parameter Location Optimizations Jun 14, 2023
@Orland0x Orland0x requested a review from pscott June 14, 2023 15:22
@codecov
Copy link

codecov bot commented Jun 14, 2023

Codecov Report

Merging #199 (438b4f6) into main (c73eb71) will decrease coverage by 1.04%.
The diff coverage is 55.00%.

@@            Coverage Diff             @@
##             main     #199      +/-   ##
==========================================
- Coverage   83.25%   82.22%   -1.04%     
==========================================
  Files          29       29              
  Lines         442      450       +8     
  Branches      112      114       +2     
==========================================
+ Hits          368      370       +2     
- Misses         57       64       +7     
+ Partials       17       16       -1     
Impacted Files Coverage Δ
src/utils/SXUtils.sol 0.00% <0.00%> (ø)
src/utils/SignatureVerifier.sol 93.33% <ø> (ø)
src/Space.sol 96.18% <83.33%> (+0.79%) ⬆️
src/utils/PropositionPower.sol 100.00% <100.00%> (ø)

@pscott
Copy link
Collaborator

pscott commented Jun 15, 2023

It would be nice to move those _verify* to calldata and investigate those errors. Maybe we can create a tracking issue and still merge this #199 .

For _assertProposalExists, agreed the abstraction is probably worth it!

@Orland0x
Copy link
Contributor Author

It would be nice to move those _verify* to calldata and investigate those errors. Maybe we can create a tracking issue and still merge this #199 .

For _assertProposalExists, agreed the abstraction is probably worth it!

could use structs its just a bit of a faf

Copy link
Collaborator

@pscott pscott left a comment

Choose a reason for hiding this comment

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

tACK

@Orland0x Orland0x merged commit ea3d686 into main Jun 15, 2023
@Orland0x Orland0x deleted the fix_function_param_locations branch October 11, 2023 10:37
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 this pull request may close these issues.

audit: Function Parameter Location Optimizations
2 participants