Writing upgradable contracts with upgradable storage
All examples and techniques shown so far in this chapter were dealing with future changes in contract functions. The changes to the functions are generally more than the storage variables. However, the contract variable may require changes. In such cases, there is an additional design pattern that should be implemented alongside the others that were shown earlier in this chapter. This pattern helps in creating upgradable storage variables.
Storage variables are stored in persistent storage, with dynamic types such as arrays and mappings treated differently from native types such as Booleans and integers. Native types are stored in sequence one after another, while arrays and mappings are stored at different locations. Instead of placing variables consecutively in sequence, we can determine the location of these variables dynamically and store our data there. We can create some placeholder variables to start with and store newer...