Define how inheritance affects storage

This commit is contained in:
William Entriken 2018-11-14 22:55:19 -05:00 committed by chriseth
parent 7921e5f0b9
commit b98a9eeb97

View File

@ -15,6 +15,10 @@ Statically-sized variables (everything except mapping and dynamically-sized arra
- If an elementary type does not fit the remaining part of a storage slot, it is moved to the next storage slot. - If an elementary type does not fit the remaining part of a storage slot, it is moved to the next storage slot.
- Structs and array data always start a new slot and occupy whole slots (but items inside a struct or array are packed tightly according to these rules). - Structs and array data always start a new slot and occupy whole slots (but items inside a struct or array are packed tightly according to these rules).
For contracts that use inheritance, the ordering of state variables is determined by the
C3-linearized order of contracts starting with the most base-ward contract. If allowed
by the above rules, state variables from different contracts do share the same storage slot.
.. warning:: .. warning::
When using elements that are smaller than 32 bytes, your contract's gas usage may be higher. When using elements that are smaller than 32 bytes, your contract's gas usage may be higher.
This is because the EVM operates on 32 bytes at a time. Therefore, if the element is smaller This is because the EVM operates on 32 bytes at a time. Therefore, if the element is smaller