To make my contract upgradable, I have a proxy contract that stores all of my data.

As I understand it, when using delegatecall the storage layout needs to match for both the caller and callee. Due to the nature of my contract, I have many mappings that are subject to change on upgrades. Do these need to be defined in both contracts? Am I at risk of corrupting storage if not?

My thought is no, since mappings are not stored the same way and do not have fixed sizes. I want to be sure though.

  • 1
    This article medium.com/@hayeah/… explain how mapping are allocated in the contract storage. If you only modify code, ie functions, you should be ok. If you add/remove a storage variable, you are changing the storage layout and an upgrade will not work.
    – Ismael
    Nov 10, 2017 at 6:20

1 Answer 1


Your map data should be fine. As in this blog post The formula for calculating the storage address for a map key is keccak256(bytes32(key) + bytes32(position)).

The main risk is if you change the version of the solidity compiler in the new delegate contract and they change the formula above. I would suggest having a test against the assembly code to ensure the computed addresses are the same, or just never change the version of solidity you are using.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.