DEV Community

Discussion on: Understanding Diamonds on Ethereum

Collapse
 
gavinzheng profile image
Gavin Zheng • Edited

Great article !!! I am working on developing NFT artifacts by using Diamond standard. I still am unclear about several points in Diamond standard:

  1. Based on my understanding, the mapping key is function selector. What if different facets have the same function signature? For example : FacetA has a function setfacet() and FacetB has a function with the same function prototype like setfacet(). I think it will cause name conflict.
  2. How contract storage can be upgraded? If I define all the contract storage in Diamond contract, and if I need to add a new state variable when I need to upgrade some facet , what I should do?
  3. is there any design addressing how to access older contract code and storage? Is there any plan to add version control to manage contract code and storage

Thanks in advance

Collapse
 
mudgen profile image
Nick Mudge

Great questions Gavin.

The diamondCut function which adds/replaces/removes functions prevents the same function selectors from being added.

Contract storage can be upgraded by adding state variables to the ends of structs. Also more areas of storage can be accessed using diamond storage. Info on that here: dev.to/mudgen/how-diamond-storage-...

I use git to manage contract source code. I use git tags to label deployments and upgrades to help keep track of things. It would be great if more tools and/or practices were published about this.