Failed to compile modified contracts for namespaced storage, missing implementation
Hardhat compilation error with OpenZeppelin upgrades plugin: Mismatch in function return type
Description
When compiling my Solidity contracts using Hardhat, I encounter a compilation error that only occurs when the OpenZeppelin upgrades plugin is imported in the hardhat.config.ts file. The error suggests a mismatch in the return type of a function between the interface and its implementation.
Steps to Reproduce
- Create two Solidity files:
-
IVersionableResolver.sol(interface) -
ResolverAbs.sol(abstract contract implementing the interface)
-
- In
hardhat.config.ts, import the OpenZeppelin upgrades plugin:import '@openzeppelin/hardhat-upgrades'; - Run
npx hardhat compile
Error message
Note: Missing implementation: --> contracts/interfaces/IVersionableResolver.sol:7:5: | 7 | function recordVersions(bytes32 node) external view returns (bool);
Seems like the compiler recognizes the return value as bool, but the actual return value is uint64
Additional Information
- The compilation succeeds if the OpenZeppelin upgrades plugin import is removed from hardhat.config.ts.
- Solidity version: ^0.8.24
- Hardhat version: 2.22.6
- openzeppelin/hardhat-upgrades version: 3.2.0
- openzeppelin/contracts-upgradeable version: 5.0.2
- openzeppelin/upgrades-core: 1.34.4
IVersionableResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
interface IVersionableResolver {
event VersionChanged(bytes32 indexed node, uint64 newVersion);
function recordVersions(bytes32 node) external view returns (uint64);
}
ResolverAbs.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol";
import "../interfaces/IVersionableResolver.sol";
abstract contract ResolverAbs is ERC165Upgradeable, IVersionableResolver {
// node -> node version
mapping(bytes32 => uint64) public recordVersions;
function isAuthorized(bytes32 node) internal view virtual returns (bool);
modifier authorized(bytes32 node) {
require(isAuthorized(node), "ResolverAbs: not authorized");
_;
}
/**
* Increments the record version associated with a MagicDomains node.
* May only be called by the owner of that node in the MagicDomains registry.
* @param node The node to update.
*/
function clearRecords(bytes32 node) public virtual authorized(node) {
recordVersions[node]++;
emit VersionChanged(node, recordVersions[node]);
}
function supportsInterface(
bytes4 interfaceID
) public view virtual override returns (bool) {
return
interfaceID == type(IVersionableResolver).interfaceId ||
super.supportsInterface(interfaceID);
}
}
I am getting the exact same error.
After I removed openzeppelin/hardhat-upgrades
I was able to compile again my contracts. But I can still not execute any script or task that makes use of upgrades package
I can see an update to the packages 8days ago before this one everything worked.
@ericglau
I am using for example the Poll contract https://github.com/privacy-scaling-explorations/maci/blob/dev/contracts/contracts/Poll.sol and getting the error depicted below.
When I delete the import of hardhat-upgrades from hardhat.config.ts then it compiles.
But in my workflow I still make use of upgrades so that issue is blocking me