Problem with adding state variable to Base contract in upgradable Contract

I use upgradable smart contract .I have several Base contracts that use in my Main contract, Base contracts have __gap . when I add state variable to Base contract and reduce __gap array , I get this Error :

//For New Variable that added to Base contract

New variables should be placed after all existing inherited variables

//For reduce __gap array size in Base contract

  • Bad array resize from 49 to 48
    Size cannot decrease

:1234: Code to reproduce

abstract contract Base1 {
  uint256 val1;
  uint256[49] private ______gap;
}

abstract contract Base2 {
  uint256 val2;
  uint256[49] private ______gap;
}

contract Child is Base1, Base2 {

}

and new contracts:

abstract contract Base1V2 {
  uint256 val1;
  uint256 val3;

  uint256[48] private ______gap;
}

abstract contract Base2 {
  uint256 val2;
  uint256[49] private ______gap;
}

contract Child is Base1V2, Base2 {}

:computer: Environment

I am using Truffle and uups upgradable proxy

Hi @Reza_ghasemi, this is not supported by the plugin yet. There is an issue open for it here. For a workaround, please see the below:

1 Like