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

💡Idea: Don't Kill Me #359

Open
RogerPodacter opened this issue Apr 7, 2023 · 1 comment
Open

💡Idea: Don't Kill Me #359

RogerPodacter opened this issue Apr 7, 2023 · 1 comment

Comments

@RogerPodacter
Copy link
Contributor

BUT, what about: Solady-style implementation of Diamond Storage. You've ADMITTED Diamond Storage is good, you basically use it across all these libraries (and the A contract), and in ERC721 you've really made it "lean and mean" with the whole _ERC721_MASTER_SLOT_SEED thing ChatGPT is explaining to me!

I'm not sure exactly what the interface would be for the person using the lib, but there must be an option. I'm also not sure how you would give users the ability to "add new members to existing structs," but I think that's a bad idea anyway so all the better if users can't do it!

Again, don't kill me, just calling it how I see it!

@gauravjaincr7
Copy link

In Simple Terms:
Diamond Storage is a pattern used in smart contract development to reduce gas costs and improve contract upgradability. It allows for data to be stored in a single contract and accessed by multiple contracts. This pattern is commonly used in ERC721 and other token standards.

In a Solady-style implementation of Diamond Storage, the focus would be on minimizing the code size and gas costs while maintaining the benefits of Diamond Storage. Solady is a framework for developing efficient and secure smart contracts on Solana.

One approach to implementing Diamond Storage in a Solady-style could be to use a single state struct to store all the data related to the contract. This state struct can be defined in a separate file and imported into the contract. The contract can then access the state struct using a global variable.

To allow for adding new members to the state struct, the contract can include a function that modifies the state struct. However, this should be done with caution as it can potentially introduce security vulnerabilities and impact the contract upgradability.

Overall, implementing Diamond Storage in a Solady-style requires careful consideration of the trade-offs between code size, gas costs, and contract upgradability. The interface for the library would depend on the specific use case and requirements.

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

No branches or pull requests

2 participants