You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
name: Adding Diamond Storage to Auth & Election Storage
about: Implementing diamond storage on current elections & auth
Describe the purpose
The Current data state's implementation of Authentication.sol & ElectionStorage.sol uses the default storage ways for storing user data & the elections.
This standard way of storage is pointless as it breaks the purpose of diamond upgradability which works on shared storage.
Possible Implementation
We can use the official Diamond Storage which accesses a memory slot in the contract.
Additional context To implement this we access the data slots the same way LibDiamond.sol reads & allocates storage slots for functionToFacet selector in diamond. Below is an example implementation of how this works.
-> I was thinking of implemeting this storage contract only on Authentication and ElectionStorage.sol as these 2 Contracts cover the user and election data and the rest contracts are brought from the elections storage.
The text was updated successfully, but these errors were encountered:
name: Adding Diamond Storage to Auth & Election Storage
about: Implementing diamond storage on current elections & auth
Describe the purpose
![Screenshot 2024-01-30 at 12 39 11 AM](https://private-user-images.githubusercontent.com/101713157/300576971-784ad366-4e8a-46e4-b89c-259c8202dddf.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxNTQzMjgsIm5iZiI6MTcyNjE1NDAyOCwicGF0aCI6Ii8xMDE3MTMxNTcvMzAwNTc2OTcxLTc4NGFkMzY2LTRlOGEtNDZlNC1iODljLTI1OWM4MjAyZGRkZi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwOTEyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDkxMlQxNTEzNDhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1kNDk4MmFkOGRjODY4M2JlMzc3NTVmNjA0M2M4Zjk4ZGVkNjRjYWFmYmM5ZTEwNDI1MjAzMTFmMGQ2Yjk5MWM2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.nP_qQjU-MspYF10aspy1-voA28LWq8ttcw6ALZMyjqE)
![Screenshot 2024-01-30 at 12 39 19 AM](https://private-user-images.githubusercontent.com/101713157/300576982-6059b170-b531-4434-bac9-392170c07ea7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxNTQzMjgsIm5iZiI6MTcyNjE1NDAyOCwicGF0aCI6Ii8xMDE3MTMxNTcvMzAwNTc2OTgyLTYwNTliMTcwLWI1MzEtNDQzNC1iYWM5LTM5MjE3MGMwN2VhNy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwOTEyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDkxMlQxNTEzNDhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1jZGM2ZDJlNjk3ZDk5ZWZmODU2NjVkMDBjY2U0YWRkNGRmNGNlNjRmYzA0MDNlZmY5MWMyODUwOThmMGRjNWU2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.lwwKIdNCl5McdDKTo_FqHWpFMlGBeTMoJbC0KzZ3RYc)
The Current data state's implementation of Authentication.sol & ElectionStorage.sol uses the default storage ways for storing user data & the elections.
This standard way of storage is pointless as it breaks the purpose of diamond upgradability which works on shared storage.
Possible Implementation
We can use the official Diamond Storage which accesses a memory slot in the contract.
![Screenshot 2024-01-30 at 12 42 15 AM](https://private-user-images.githubusercontent.com/101713157/300577657-f69ea625-15b2-4834-a98e-5b84eafa488b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxNTQzMjgsIm5iZiI6MTcyNjE1NDAyOCwicGF0aCI6Ii8xMDE3MTMxNTcvMzAwNTc3NjU3LWY2OWVhNjI1LTE1YjItNDgzNC1hOThlLTViODRlYWZhNDg4Yi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwOTEyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDkxMlQxNTEzNDhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0xODdiNjQ2NWY0YTA2M2ViMTk0ZjgzOGVjMmU0NDEzNjUxNTEyOTllMWZlYjdkMDM0ZDA4NzMxNmRkZmVkODEyJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.7Y8Ad63usBvQ3RdWxZzyql4Wc6njgKYd26rQHOQKYiw)
Additional context To implement this we access the data slots the same way LibDiamond.sol reads & allocates storage slots for functionToFacet selector in diamond. Below is an example implementation of how this works.
![Screenshot 2024-01-30 at 12 46 21 AM](https://private-user-images.githubusercontent.com/101713157/300578438-cd127940-377a-4602-ab7a-258618daf01e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxNTQzMjgsIm5iZiI6MTcyNjE1NDAyOCwicGF0aCI6Ii8xMDE3MTMxNTcvMzAwNTc4NDM4LWNkMTI3OTQwLTM3N2EtNDYwMi1hYjdhLTI1ODYxOGRhZjAxZS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwOTEyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDkxMlQxNTEzNDhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1jNTgxMTVlMjVmNDM1NjZlYzg0ZjMwZjdmYTk0Y2Q0NmYyMjdjMGZjOGRmMWFlNTVmMmQzZWEyNmUyMjk3ZTJmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.D_PQl-jTsFwUEO25aSBDuc0jQFn48dC_iii9whXijxo)
-> I was thinking of implemeting this storage contract only on Authentication and ElectionStorage.sol as these 2 Contracts cover the user and election data and the rest contracts are brought from the elections storage.
The text was updated successfully, but these errors were encountered: