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

feat(smart-contracts): lower contract size for PublicLock v15 #14846

Merged
merged 33 commits into from
Oct 30, 2024

Conversation

clemsos
Copy link
Member

@clemsos clemsos commented Oct 16, 2024

Description

This removes some code from PublicLock template so more features can be added without hitting the EVM contract size limit

Size: before : 23.956 / after: 22.636

Make some function private (avoid storing/copying full signature)

  • schemaVersion (-0.032)
  • set updateSchemaVersion internal (?)

Functions removed

  • addLockManager (duplicate of hasRole(LOCK_MANAGER_ROLE, address)) and renounceLockManager (duplicate of renounceRole(LOCK_MANAGER_ROLE)) (-0.220)
  • remove isApprovedForAll and setApprovalForAll(-0.477)
  • refactor hooks addresses getters into a single hooks getter (-0.061)

Other cleanup

  • remove previous migration code (-0.188)
  • refactor hooks addresses checks (-0.349)

NOT doing:

  • group fees into a single getter and a single setter (gas refund, transfer fee, cancel fee) (+0.063)
  • refactor hooks addresses getters into a single hooks getter (-0.061)

Potential candidates for deletion

  • function where feature can be recreated with workarounds : burn
  • 'nice to have' / sad to delete functions : lendKey / unlendKey, mergeKeys

Issues

Fixes #
Refs #

Checklist:

  • 1 PR, 1 purpose: my Pull Request applies to a single purpose
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the docs to reflect my changes if applicable
  • I have added tests (and stories for frontend components) that prove my fix is effective or that my feature works
  • I have performed a self-review of my own code
  • If my code involves visual changes, I am adding applicable screenshots to this thread

Release Note Draft Snippet

@clemsos clemsos requested a review from julien51 October 16, 2024 10:11
@cla-bot cla-bot bot added the cla-signed label Oct 16, 2024
@clemsos
Copy link
Member Author

clemsos commented Oct 17, 2024

contract size audit here https://observablehq.com/d/fcfc7fa77ef2dd13

Copy link
Member

@julien51 julien51 left a comment

Choose a reason for hiding this comment

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

I think this is good!

@clemsos clemsos merged commit 69e265a into master Oct 30, 2024
14 checks passed
@clemsos clemsos deleted the lower-lock-contract-size-v15 branch October 30, 2024 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants