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

refactor(contracts): optimize code #1008

Merged
merged 1 commit into from
Jan 12, 2024
Merged

Conversation

ctrlc03
Copy link
Collaborator

@ctrlc03 ctrlc03 commented Jan 11, 2024

Description

Optimize code by using immutable variables are removing redundant code.

Confirmation

Copy link

netlify bot commented Jan 11, 2024

Deploy Preview for maci-typedoc ready!

Name Link
🔨 Latest commit d39d384
🔍 Latest deploy log https://app.netlify.com/sites/maci-typedoc/deploys/65a1a7459fa3460008c5fe6c
😎 Deploy Preview https://deploy-preview-1008--maci-typedoc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@ctrlc03 ctrlc03 self-assigned this Jan 11, 2024
@ctrlc03 ctrlc03 added the smart contracts Related to the Solidity smart contracts label Jan 11, 2024
@ctrlc03 ctrlc03 force-pushed the refactor/contracts-optimizations branch from bf8415f to 9a83eba Compare January 11, 2024 23:10
Copy link
Collaborator

@0xmad 0xmad left a comment

Choose a reason for hiding this comment

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

@ctrlc03 thanks, just one question. Do we need to support the same state for deployed smart contracts? As far as I know, if someone tries to redeploy these contracts using proxies, it won't work because state if not the same.
In case if we don't care about it, I'm good with these changes.

@ctrlc03
Copy link
Collaborator Author

ctrlc03 commented Jan 12, 2024

@ctrlc03 thanks, just one question. Do we need to support the same state for deployed smart contracts? As far as I know, if someone tries to redeploy these contracts using proxies, it won't work because state if not the same. In case if we don't care about it, I'm good with these changes.

Could you please expand on that? do you mean because of immutable parameters? if so, there's libraries for proxy clones with immutable args: https://github.com/wighawag/clones-with-immutable-args

@0xmad
Copy link
Collaborator

0xmad commented Jan 12, 2024

@ctrlc03 thanks, just one question. Do we need to support the same state for deployed smart contracts? As far as I know, if someone tries to redeploy these contracts using proxies, it won't work because state if not the same. In case if we don't care about it, I'm good with these changes.

Could you please expand on that? do you mean because of immutable parameters? if so, there's libraries for proxy clones with immutable args: https://github.com/wighawag/clones-with-immutable-args

I had some issues after adding immutable which causes storage layout change. But if it's not a case, let's leave it.

@ctrlc03
Copy link
Collaborator Author

ctrlc03 commented Jan 12, 2024

@ctrlc03 thanks, just one question. Do we need to support the same state for deployed smart contracts? As far as I know, if someone tries to redeploy these contracts using proxies, it won't work because state if not the same. In case if we don't care about it, I'm good with these changes.

Could you please expand on that? do you mean because of immutable parameters? if so, there's libraries for proxy clones with immutable args: https://github.com/wighawag/clones-with-immutable-args

I had some issues after adding immutable which causes storage layout change. But if it's not a case, let's leave it.

issues when upgrading? I've not tried these contracts with any proxy pattern before tbf

@0xmad
Copy link
Collaborator

0xmad commented Jan 12, 2024

@ctrlc03 thanks, just one question. Do we need to support the same state for deployed smart contracts? As far as I know, if someone tries to redeploy these contracts using proxies, it won't work because state if not the same. In case if we don't care about it, I'm good with these changes.

Could you please expand on that? do you mean because of immutable parameters? if so, there's libraries for proxy clones with immutable args: https://github.com/wighawag/clones-with-immutable-args

I had some issues after adding immutable which causes storage layout change. But if it's not a case, let's leave it.

issues when upgrading? I've not tried these contracts with any proxy pattern before tbf

Yes, it's related to upgrades

@ctrlc03
Copy link
Collaborator Author

ctrlc03 commented Jan 12, 2024

@ctrlc03 thanks, just one question. Do we need to support the same state for deployed smart contracts? As far as I know, if someone tries to redeploy these contracts using proxies, it won't work because state if not the same. In case if we don't care about it, I'm good with these changes.

Could you please expand on that? do you mean because of immutable parameters? if so, there's libraries for proxy clones with immutable args: https://github.com/wighawag/clones-with-immutable-args

I had some issues after adding immutable which causes storage layout change. But if it's not a case, let's leave it.

issues when upgrading? I've not tried these contracts with any proxy pattern before tbf

Yes, it's related to upgrades

oh that makes sense then! I don't think MACI as a protocol should use upgradable proxies, to enhance transparency. On the other hand, at some point we should definitely consider using clone proxies (or another efficient method) to deploy instances. What do you think?

@0xmad
Copy link
Collaborator

0xmad commented Jan 12, 2024

@ctrlc03 I think yes, at least we need to know community about that because someone else can use it with proxies and it can be a problem after upgrade with storage layout.
From our side, I think it will be useful to have something which helps to reduce gas for deployment or even better user can just use already deployed contracts.

@ctrlc03
Copy link
Collaborator Author

ctrlc03 commented Jan 12, 2024

@ctrlc03 I think yes, at least we need to know community about that because someone else can use it with proxies and it can be a problem after upgrade with storage layout. From our side, I think it will be useful to have something which helps to reduce gas for deployment or even better user can just use already deployed contracts.

Definitely agree! Yes being able to use already deployed contracts and just point a proxy to it would be fantastic. Let's merge this after #949 ?

@0xmad
Copy link
Collaborator

0xmad commented Jan 12, 2024

@ctrlc03 sure, thanks!

@ctrlc03 ctrlc03 force-pushed the refactor/contracts-optimizations branch from 9a83eba to d39d384 Compare January 12, 2024 20:55
@ctrlc03 ctrlc03 enabled auto-merge January 12, 2024 20:57
@ctrlc03 ctrlc03 merged commit c2ee394 into dev Jan 12, 2024
17 checks passed
@ctrlc03 ctrlc03 deleted the refactor/contracts-optimizations branch January 12, 2024 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
smart contracts Related to the Solidity smart contracts
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants