Skip to content

Struct Field Addition Flagged as Incompatible Upgrade #1163

Closed as duplicate of#1136
@yashnaman

Description

@yashnaman
npx @openzeppelin/upgrades-core@1.41.0 validate --contract Pool --referenceBuildInfoDirs out-v1/build-info-v1 --reference build-info-v1:pool

I'm using upgrades-core 'svalidate command to compare two versions of the Pool contract. The only change between the versions is an addition to a struct:

  • The Pool contract has a single state variable: a struct named PoolState.
  • I added a uint256 variable at the end of the PoolState struct.

Expected Behavior:

Since the new field is appended to the end of the struct and there is no other state after the struct, this should not cause any storage layout issues.

Observed Behavior:

Despite the safe change, I get the following error:

src/Pool.sol:9: Upgraded `pool` to an incompatible type
  - Bad upgrade to struct PoolState
  - In struct PoolState
    - Added `additionalUint256`

Why is this considered an incompatible upgrade?
Is this a false positive, or is there something I'm missing about how OpenZeppelin detects unsafe changes to structs?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions