What are the effects of adding new members in a struct in Transparent Upgradeable contracts

If I have a transparent upgradeable contract deployed with a struct:

struct ABC{
    uint8 a;
    uint8 b;
    uint8 c:
}

And this struct is used in storage variables, in mappings.

What will happen when I add new members in this struct for the next version of implementation.

struct ABC{
    uint8 a;
    uint8 b;
    uint8 c:
    uint8 d:
    uint8 e:
}

How will it affect the storage layout in the proxy?

The answer depends on the actual storage layout in your contract; please share it.

1 Like

Here is the code

There are 5 contracts here, am I supposed to guess which one of them is the relevant one?

Please post ALL the relevant code and ONLY the relevant code.

As I wrote above - the only code which is relevant to your question, is the storage layout of your contract (i.e., the contract's state variables in the exact order of declaration).

And please post it in plaintext (no links or images).

Those five files make up a the whole system, that's why I shared all of them. Let me break it down for you.

EPNSCoreAdmin.sol is the proxy admin.

EPNSCoreProxy.sol Is the proxy

PushCoreStorageV1_5.sol and PushCoreStorageV2.sol are the storage contracts, you can see all the storage variables being defined here.

Finally PushCoreV2.sol is the implementation contract which inherits the storage contracts.

As far as I know, it is safe to do so only if no state variable other than the very one in your contract is of this type.

There is no struct ABC in the code that you've linked above, so I cannot refer to your question specifically with respect to that code.

okay, so if the struct is used as a storage variable then adding more members to it can alter the storage layout, right?

struct ABC was just an example, you can consider any struct from the contract, as all of them are used as storage variables.

"Safe to do" = Safe to add fields at the end of that structure, as illustrated in your question.

1 Like