Storage layout validation fails with user-defined types

Hi all,

I'm using Solidity 0.8.14 and OpenZeppelin contracts-upgradeable 4.6.0. I'm running into an issue when trying to define a user-defined type. Compilation breaks and I get an:

Error: No node with id 5897 of type StructDefinition,EnumDefinition

It seems to be something related to the storage layout validation run by an OZ override for the hardhat task. I've seen some github issues about it but it seems that Solidity 0.8.9 should have solved it. Not sure if that's true because being on 0.8.14 it fails. Do I need to wait for the next release of OZ contracts?

Thanks!

Can you share the current implementation contract and the new including how are you truing to include the new storage variable. Doesn't have to be the entire thing just the part regarding your issue.

Hi!

This seems to be the offending code:

PriceUtils.sol

/**
 * SPDX-License-Identifier: Apache-2.0
 */
pragma solidity 0.8.14;

import "@prb/math/contracts/PRBMathUD60x18.sol";

library PriceUtils {
    type Price is uint256;
    using PRBMathUD60x18 for uint256;

    function toOutputAmount(Price priceRate, uint256 inputAmount) internal pure returns (uint256) {
        return Price.unwrap(priceRate).mul(PRBMathUD60x18.fromUint(inputAmount)).toUint();
    }

    function toInputAmount(Price priceRate, uint256 outputAmount) internal pure returns (uint256) {
        return PRBMathUD60x18.fromUint(outputAmount).div(Price.unwrap(priceRate)).toUint();
    }
}

Even if I don't use the functions defined in the library, I get the following error:

Error: No node with id 5898 of type StructDefinition,EnumDefinition
    at deref (/home/user/Development/node_modules/@openzeppelin/upgrades-core/src/ast-dereferencer.ts:38:11)
    at /home/user/Development/node_modules/@openzeppelin/upgrades-core/src/utils/curry.ts:11:19
    at loadLayoutType (/home/user/Development/node_modules/@openzeppelin/upgrades-core/src/storage/extract.ts:137:23)
    at extractStorageLayout (/home/user/Development/node_modules/@openzeppelin/upgrades-core/src/storage/extract.ts:48:7)
    at validate (/home/user/Development/node_modules/@openzeppelin/upgrades-core/src/validate/run.ts:165:67)
    at OverriddenTaskDefinition._action (/home/user/Development/node_modules/@openzeppelin/hardhat-upgrades/src/index.ts:73:25)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Environment._runTaskDefinition (/home/user/Development/node_modules/hardhat/src/internal/core/runtime-environment.ts:219:14)
    at async Environment.run (/home/user/Development/node_modules/hardhat/src/internal/core/runtime-environment.ts:131:14)
    at async SimpleTaskDefinition.action (/home/user/Development/node_modules/hardhat/src/builtin-tasks/compile.ts:985:37)

Bump! Any idea why this is happening in 4.6.0 with 0.8.14?