Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't add variables with change of storage gap with hardhat #785

Open
jachung91 opened this issue May 3, 2023 · 1 comment
Open

Can't add variables with change of storage gap with hardhat #785

jachung91 opened this issue May 3, 2023 · 1 comment

Comments

@jachung91
Copy link

jachung91 commented May 3, 2023

I am using

hardhat v2.14.0
solidity v0.8.9

Simple code is like

original code

contract BoxV1 is Initializable{
uint256 private value;
uint256[48] private __gapUint256;}

upgrading code

contract BoxV2 is Initializable{
uint256 private value;
uint256 private amount;
uint256[47] private __gapUint256;}

but i get error when I use upgrades.upgradeProxy with hardhat.

Error is

Error: New storage layout is incompatible
contracts/BoxV2.sol:8: Inserted amount
New variables should be placed after all existing inherited variables
contracts/BoxV2.sol:9: Upgraded __gapUint256 to an incompatible type

As i read docs at https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#storage-gaps
I think i did anything wrong. Any one can help?

@ericglau
Copy link
Member

Hi @jachung91 , the gap name needs to be exactly __gap or start with __gap_ (with the extra underscore after it). In your example, can you use a gap name like __gap_uint256?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants