@openzeppelin/upgrades-core 1.20.4 → 1.20.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol/ERC1967Proxy.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol/BeaconProxy.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol/UpgradeableBeacon.dbg.json +1 -1
- package/artifacts/build-info.json +22 -16
- package/dist/storage/compare.d.ts +2 -0
- package/dist/storage/compare.d.ts.map +1 -1
- package/dist/storage/compare.js +29 -4
- package/dist/storage/compare.js.map +1 -1
- package/dist/storage/report-retype-from-contract.test.d.ts +2 -0
- package/dist/storage/report-retype-from-contract.test.d.ts.map +1 -0
- package/dist/storage/report-retype-from-contract.test.js +148 -0
- package/dist/storage/report-retype-from-contract.test.js.map +1 -0
- package/dist/storage-memory-0.5.test.d.ts +2 -0
- package/dist/storage-memory-0.5.test.d.ts.map +1 -0
- package/dist/storage-memory-0.5.test.js +74 -0
- package/dist/storage-memory-0.5.test.js.map +1 -0
- package/package.json +2 -2
- package/src/storage/compare.ts +35 -3
- package/src/storage/report-retype-from-contract.test.ts +169 -0
- package/src/storage-memory-0.5.test.ts +89 -0
- package/src/storage-memory-0.5.test.ts.md +175 -0
- package/src/storage-memory-0.5.test.ts.snap +0 -0
|
@@ -6,35 +6,35 @@
|
|
|
6
6
|
"contracts/import.sol": {
|
|
7
7
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol\";\nimport \"@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol\";\nimport \"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\";\nimport \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\nimport \"@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol\";\n\n// Kept for backwards compatibility with older versions of Hardhat and Truffle plugins.\ncontract AdminUpgradeabilityProxy is TransparentUpgradeableProxy {\n constructor(address logic, address admin, bytes memory data) payable TransparentUpgradeableProxy(logic, admin, data) {}\n}\n"
|
|
8
8
|
},
|
|
9
|
+
"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol": {
|
|
10
|
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../Proxy.sol\";\nimport \"./ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\n * implementation address that can be changed. This address is stored in storage in the location specified by\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\n * implementation behind the proxy.\n */\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\n *\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\n */\n constructor(address _logic, bytes memory _data) payable {\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.implementation\")) - 1));\n _upgradeToAndCall(_logic, _data, false);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function _implementation() internal view virtual override returns (address impl) {\n return ERC1967Upgrade._getImplementation();\n }\n}\n"
|
|
11
|
+
},
|
|
9
12
|
"@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol": {
|
|
10
13
|
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IBeacon.sol\";\nimport \"../Proxy.sol\";\nimport \"../ERC1967/ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements a proxy that gets the implementation address for each call from a {UpgradeableBeacon}.\n *\n * The beacon address is stored in storage slot `uint256(keccak256('eip1967.proxy.beacon')) - 1`, so that it doesn't\n * conflict with the storage layout of the implementation behind the proxy.\n *\n * _Available since v3.4._\n */\ncontract BeaconProxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the proxy with `beacon`.\n *\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This\n * will typically be an encoded function call, and allows initializating the storage of the proxy like a Solidity\n * constructor.\n *\n * Requirements:\n *\n * - `beacon` must be a contract with the interface {IBeacon}.\n */\n constructor(address beacon, bytes memory data) payable {\n assert(_BEACON_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.beacon\")) - 1));\n _upgradeBeaconToAndCall(beacon, data, false);\n }\n\n /**\n * @dev Returns the current beacon address.\n */\n function _beacon() internal view virtual returns (address) {\n return _getBeacon();\n }\n\n /**\n * @dev Returns the current implementation address of the associated beacon.\n */\n function _implementation() internal view virtual override returns (address) {\n return IBeacon(_getBeacon()).implementation();\n }\n\n /**\n * @dev Changes the proxy to use a new beacon. Deprecated: see {_upgradeBeaconToAndCall}.\n *\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon.\n *\n * Requirements:\n *\n * - `beacon` must be a contract.\n * - The implementation returned by `beacon` must be a contract.\n */\n function _setBeacon(address beacon, bytes memory data) internal virtual {\n _upgradeBeaconToAndCall(beacon, data, false);\n }\n}\n"
|
|
11
14
|
},
|
|
12
15
|
"@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol": {
|
|
13
16
|
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IBeacon.sol\";\nimport \"../../access/Ownable.sol\";\nimport \"../../utils/Address.sol\";\n\n/**\n * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their\n * implementation contract, which is where they will delegate all function calls.\n *\n * An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.\n */\ncontract UpgradeableBeacon is IBeacon, Ownable {\n address private _implementation;\n\n /**\n * @dev Emitted when the implementation returned by the beacon is changed.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the\n * beacon.\n */\n constructor(address implementation_) {\n _setImplementation(implementation_);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function implementation() public view virtual override returns (address) {\n return _implementation;\n }\n\n /**\n * @dev Upgrades the beacon to a new implementation.\n *\n * Emits an {Upgraded} event.\n *\n * Requirements:\n *\n * - msg.sender must be the owner of the contract.\n * - `newImplementation` must be a contract.\n */\n function upgradeTo(address newImplementation) public virtual onlyOwner {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Sets the implementation contract address for this beacon\n *\n * Requirements:\n *\n * - `newImplementation` must be a contract.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"UpgradeableBeacon: implementation is not a contract\");\n _implementation = newImplementation;\n }\n}\n"
|
|
14
17
|
},
|
|
15
|
-
"@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol": {
|
|
16
|
-
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./TransparentUpgradeableProxy.sol\";\nimport \"../../access/Ownable.sol\";\n\n/**\n * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an\n * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\n */\ncontract ProxyAdmin is Ownable {\n\n /**\n * @dev Returns the current implementation of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"implementation()\")) == 0x5c60da1b\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"5c60da1b\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Returns the current admin of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"admin()\")) == 0xf851a440\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"f851a440\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Changes the admin of `proxy` to `newAdmin`.\n *\n * Requirements:\n *\n * - This contract must be the current admin of `proxy`.\n */\n function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {\n proxy.changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {\n proxy.upgradeTo(implementation);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See\n * {TransparentUpgradeableProxy-upgradeToAndCall}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgradeAndCall(TransparentUpgradeableProxy proxy, address implementation, bytes memory data) public payable virtual onlyOwner {\n proxy.upgradeToAndCall{value: msg.value}(implementation, data);\n }\n}\n"
|
|
17
|
-
},
|
|
18
|
-
"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol": {
|
|
19
|
-
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../Proxy.sol\";\nimport \"./ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\n * implementation address that can be changed. This address is stored in storage in the location specified by\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\n * implementation behind the proxy.\n */\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\n *\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\n */\n constructor(address _logic, bytes memory _data) payable {\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.implementation\")) - 1));\n _upgradeToAndCall(_logic, _data, false);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function _implementation() internal view virtual override returns (address impl) {\n return ERC1967Upgrade._getImplementation();\n }\n}\n"
|
|
20
|
-
},
|
|
21
18
|
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol": {
|
|
22
19
|
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../ERC1967/ERC1967Proxy.sol\";\n\n/**\n * @dev This contract implements a proxy that is upgradeable by an admin.\n *\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\n * clashing], which can potentially be used in an attack, this contract uses the\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\n * things that go hand in hand:\n *\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\n * that call matches one of the admin functions exposed by the proxy itself.\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\n * \"admin cannot fallback to proxy target\".\n *\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\n * to sudden errors when trying to call a function from the proxy implementation.\n *\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\n */\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\n /**\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\n */\n constructor(address _logic, address admin_, bytes memory _data) payable ERC1967Proxy(_logic, _data) {\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.admin\")) - 1));\n _changeAdmin(admin_);\n }\n\n /**\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\n */\n modifier ifAdmin() {\n if (msg.sender == _getAdmin()) {\n _;\n } else {\n _fallback();\n }\n }\n\n /**\n * @dev Returns the current admin.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\n */\n function admin() external ifAdmin returns (address admin_) {\n admin_ = _getAdmin();\n }\n\n /**\n * @dev Returns the current implementation.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\n */\n function implementation() external ifAdmin returns (address implementation_) {\n implementation_ = _implementation();\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\n */\n function changeAdmin(address newAdmin) external virtual ifAdmin {\n _changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\n */\n function upgradeTo(address newImplementation) external ifAdmin {\n _upgradeToAndCall(newImplementation, bytes(\"\"), false);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\n * proxied contract.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\n */\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\n _upgradeToAndCall(newImplementation, data, true);\n }\n\n /**\n * @dev Returns the current admin.\n */\n function _admin() internal view virtual returns (address) {\n return _getAdmin();\n }\n\n /**\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\n */\n function _beforeFallback() internal virtual override {\n require(msg.sender != _getAdmin(), \"TransparentUpgradeableProxy: admin cannot fallback to proxy target\");\n super._beforeFallback();\n }\n}\n"
|
|
23
20
|
},
|
|
21
|
+
"@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol": {
|
|
22
|
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./TransparentUpgradeableProxy.sol\";\nimport \"../../access/Ownable.sol\";\n\n/**\n * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an\n * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\n */\ncontract ProxyAdmin is Ownable {\n\n /**\n * @dev Returns the current implementation of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"implementation()\")) == 0x5c60da1b\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"5c60da1b\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Returns the current admin of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"admin()\")) == 0xf851a440\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"f851a440\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Changes the admin of `proxy` to `newAdmin`.\n *\n * Requirements:\n *\n * - This contract must be the current admin of `proxy`.\n */\n function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {\n proxy.changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {\n proxy.upgradeTo(implementation);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See\n * {TransparentUpgradeableProxy-upgradeToAndCall}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgradeAndCall(TransparentUpgradeableProxy proxy, address implementation, bytes memory data) public payable virtual onlyOwner {\n proxy.upgradeToAndCall{value: msg.value}(implementation, data);\n }\n}\n"
|
|
23
|
+
},
|
|
24
24
|
"@openzeppelin/contracts/proxy/Proxy.sol": {
|
|
25
25
|
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n /**\n * @dev Delegates the current call to `implementation`.\n *\n * This function does not return to its internall call site, it will return directly to the external caller.\n */\n function _delegate(address implementation) internal virtual {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n // Copy msg.data. We take full control of memory in this inline assembly\n // block because it will not return to Solidity code. We overwrite the\n // Solidity scratch pad at memory position 0.\n calldatacopy(0, 0, calldatasize())\n\n // Call the implementation.\n // out and outsize are 0 because we don't know the size yet.\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n // Copy the returned data.\n returndatacopy(0, 0, returndatasize())\n\n switch result\n // delegatecall returns 0 on error.\n case 0 { revert(0, returndatasize()) }\n default { return(0, returndatasize()) }\n }\n }\n\n /**\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\n * and {_fallback} should delegate.\n */\n function _implementation() internal view virtual returns (address);\n\n /**\n * @dev Delegates the current call to the address returned by `_implementation()`.\n *\n * This function does not return to its internall call site, it will return directly to the external caller.\n */\n function _fallback() internal virtual {\n _beforeFallback();\n _delegate(_implementation());\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n * function in the contract matches the call data.\n */\n fallback () external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n * is empty.\n */\n receive () external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n * call, or as part of the Solidity `fallback` or `receive` functions.\n *\n * If overriden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {\n }\n}\n"
|
|
26
26
|
},
|
|
27
|
-
"@openzeppelin/contracts/proxy/beacon/IBeacon.sol": {
|
|
28
|
-
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n"
|
|
29
|
-
},
|
|
30
27
|
"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol": {
|
|
31
28
|
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeacon.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/StorageSlot.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n *\n * @custom:oz-upgrades-unsafe-allow delegatecall\n */\nabstract contract ERC1967Upgrade {\n // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Emitted when the implementation is upgraded.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Returns the current implementation address.\n */\n function _getImplementation() internal view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 implementation slot.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Perform implementation upgrade\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeTo(address newImplementation) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Perform implementation upgrade with additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(newImplementation, data);\n }\n }\n\n /**\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCallSecure(address newImplementation, bytes memory data, bool forceCall) internal {\n address oldImplementation = _getImplementation();\n\n // Initial upgrade and setup call\n _setImplementation(newImplementation);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(newImplementation, data);\n }\n\n // Perform rollback test if not already in progress\n StorageSlot.BooleanSlot storage rollbackTesting = StorageSlot.getBooleanSlot(_ROLLBACK_SLOT);\n if (!rollbackTesting.value) {\n // Trigger rollback using upgradeTo from the new implementation\n rollbackTesting.value = true;\n Address.functionDelegateCall(\n newImplementation,\n abi.encodeWithSignature(\n \"upgradeTo(address)\",\n oldImplementation\n )\n );\n rollbackTesting.value = false;\n // Check rollback was effective\n require(oldImplementation == _getImplementation(), \"ERC1967Upgrade: upgrade breaks further upgrades\");\n // Finally reset to the new implementation and log the upgrade\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n }\n\n /**\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n *\n * Emits a {BeaconUpgraded} event.\n */\n function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {\n _setBeacon(newBeacon);\n emit BeaconUpgraded(newBeacon);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n }\n }\n\n /**\n * @dev Storage slot with the admin of the contract.\n * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Emitted when the admin account has changed.\n */\n event AdminChanged(address previousAdmin, address newAdmin);\n\n /**\n * @dev Returns the current admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 admin slot.\n */\n function _setAdmin(address newAdmin) private {\n require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n */\n function _changeAdmin(address newAdmin) internal {\n emit AdminChanged(_getAdmin(), newAdmin);\n _setAdmin(newAdmin);\n }\n\n /**\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n */\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n /**\n * @dev Emitted when the beacon is upgraded.\n */\n event BeaconUpgraded(address indexed beacon);\n\n /**\n * @dev Returns the current beacon.\n */\n function _getBeacon() internal view returns (address) {\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\n }\n\n /**\n * @dev Stores a new beacon in the EIP1967 beacon slot.\n */\n function _setBeacon(address newBeacon) private {\n require(\n Address.isContract(newBeacon),\n \"ERC1967: new beacon is not a contract\"\n );\n require(\n Address.isContract(IBeacon(newBeacon).implementation()),\n \"ERC1967: beacon implementation is not a contract\"\n );\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n }\n}\n"
|
|
32
29
|
},
|
|
30
|
+
"@openzeppelin/contracts/utils/StorageSlot.sol": {
|
|
31
|
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n}\n"
|
|
32
|
+
},
|
|
33
33
|
"@openzeppelin/contracts/utils/Address.sol": {
|
|
34
34
|
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize, which returns 0 for contracts in\n // construction, since the code is only stored at the end of the\n // constructor execution.\n\n uint256 size;\n // solhint-disable-next-line no-inline-assembly\n assembly { size := extcodesize(account) }\n return size > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\n (bool success, ) = recipient.call{ value: amount }(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain`call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.call{ value: value }(data);\n return _verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.staticcall(data);\n return _verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return _verifyCallResult(success, returndata, errorMessage);\n }\n\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n"
|
|
35
35
|
},
|
|
36
|
-
"@openzeppelin/contracts/
|
|
37
|
-
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev
|
|
36
|
+
"@openzeppelin/contracts/proxy/beacon/IBeacon.sol": {
|
|
37
|
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n"
|
|
38
38
|
},
|
|
39
39
|
"@openzeppelin/contracts/access/Ownable.sol": {
|
|
40
40
|
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor () {\n address msgSender = _msgSender();\n _owner = msgSender;\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n _;\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n _owner = address(0);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n emit OwnershipTransferred(_owner, newOwner);\n _owner = newOwner;\n }\n}\n"
|
|
@@ -42,30 +42,36 @@
|
|
|
42
42
|
"@openzeppelin/contracts/utils/Context.sol": {
|
|
43
43
|
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/*\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n return msg.data;\n }\n}\n"
|
|
44
44
|
},
|
|
45
|
+
"contracts/test/Memory08.sol": {
|
|
46
|
+
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\ncontract Memory08 {\n mapping(string => address) a;\n mapping(bytes => address) b;\n}\n\ncontract Memory08Bad {\n mapping(bytes => address) a;\n mapping(string => address) b;\n}\n"
|
|
47
|
+
},
|
|
45
48
|
"contracts/test/Proxiable.sol": {
|
|
46
49
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.2;\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol\";\n\nabstract contract Proxiable is UUPSUpgradeable {\n function _authorizeUpgrade(address newImplementation) internal override {\n _beforeUpgrade(newImplementation);\n }\n\n function _beforeUpgrade(address newImplementation) internal virtual;\n}\n\ncontract ChildOfProxiable is Proxiable {\n function _beforeUpgrade(address newImplementation) internal virtual override {}\n}\n"
|
|
47
50
|
},
|
|
48
51
|
"@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol": {
|
|
49
52
|
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../ERC1967/ERC1967UpgradeUpgradeable.sol\";\nimport \"./Initializable.sol\";\n\n/**\n * @dev Base contract for building openzeppelin-upgrades compatible implementations for the {ERC1967Proxy}. It includes\n * publicly available upgrade functions that are called by the plugin and by the secure upgrade mechanism to verify\n * continuation of the upgradability.\n *\n * The {_authorizeUpgrade} function MUST be overridden to include access restriction to the upgrade mechanism.\n *\n * _Available since v4.1._\n */\nabstract contract UUPSUpgradeable is Initializable, ERC1967UpgradeUpgradeable {\n function __UUPSUpgradeable_init() internal initializer {\n __ERC1967Upgrade_init_unchained();\n __UUPSUpgradeable_init_unchained();\n }\n\n function __UUPSUpgradeable_init_unchained() internal initializer {\n }\n function upgradeTo(address newImplementation) external virtual {\n _authorizeUpgrade(newImplementation);\n _upgradeToAndCallSecure(newImplementation, bytes(\"\"), false);\n }\n\n function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual {\n _authorizeUpgrade(newImplementation);\n _upgradeToAndCallSecure(newImplementation, data, true);\n }\n\n function _authorizeUpgrade(address newImplementation) internal virtual;\n uint256[50] private __gap;\n}\n"
|
|
50
53
|
},
|
|
51
|
-
"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
|
|
52
|
-
"content": "// SPDX-License-Identifier: MIT\n\n// solhint-disable-next-line compiler-version\npragma solidity ^0.8.0;\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n */\nabstract contract Initializable {\n\n /**\n * @dev Indicates that the contract has been initialized.\n */\n bool private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Modifier to protect an initializer function from being invoked twice.\n */\n modifier initializer() {\n require(_initializing || !_initialized, \"Initializable: contract is already initialized\");\n\n bool isTopLevelCall = !_initializing;\n if (isTopLevelCall) {\n _initializing = true;\n _initialized = true;\n }\n\n _;\n\n if (isTopLevelCall) {\n _initializing = false;\n }\n }\n}\n"
|
|
53
|
-
},
|
|
54
54
|
"@openzeppelin/contracts-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol": {
|
|
55
55
|
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeaconUpgradeable.sol\";\nimport \"../../utils/AddressUpgradeable.sol\";\nimport \"../../utils/StorageSlotUpgradeable.sol\";\nimport \"../utils/Initializable.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n *\n * @custom:oz-upgrades-unsafe-allow delegatecall\n */\nabstract contract ERC1967UpgradeUpgradeable is Initializable {\n function __ERC1967Upgrade_init() internal initializer {\n __ERC1967Upgrade_init_unchained();\n }\n\n function __ERC1967Upgrade_init_unchained() internal initializer {\n }\n // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Emitted when the implementation is upgraded.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Returns the current implementation address.\n */\n function _getImplementation() internal view returns (address) {\n return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 implementation slot.\n */\n function _setImplementation(address newImplementation) private {\n require(AddressUpgradeable.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Perform implementation upgrade\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeTo(address newImplementation) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Perform implementation upgrade with additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n if (data.length > 0 || forceCall) {\n _functionDelegateCall(newImplementation, data);\n }\n }\n\n /**\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCallSecure(address newImplementation, bytes memory data, bool forceCall) internal {\n address oldImplementation = _getImplementation();\n\n // Initial upgrade and setup call\n _setImplementation(newImplementation);\n if (data.length > 0 || forceCall) {\n _functionDelegateCall(newImplementation, data);\n }\n\n // Perform rollback test if not already in progress\n StorageSlotUpgradeable.BooleanSlot storage rollbackTesting = StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT);\n if (!rollbackTesting.value) {\n // Trigger rollback using upgradeTo from the new implementation\n rollbackTesting.value = true;\n _functionDelegateCall(\n newImplementation,\n abi.encodeWithSignature(\n \"upgradeTo(address)\",\n oldImplementation\n )\n );\n rollbackTesting.value = false;\n // Check rollback was effective\n require(oldImplementation == _getImplementation(), \"ERC1967Upgrade: upgrade breaks further upgrades\");\n // Finally reset to the new implementation and log the upgrade\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n }\n\n /**\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n *\n * Emits a {BeaconUpgraded} event.\n */\n function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {\n _setBeacon(newBeacon);\n emit BeaconUpgraded(newBeacon);\n if (data.length > 0 || forceCall) {\n _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);\n }\n }\n\n /**\n * @dev Storage slot with the admin of the contract.\n * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Emitted when the admin account has changed.\n */\n event AdminChanged(address previousAdmin, address newAdmin);\n\n /**\n * @dev Returns the current admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 admin slot.\n */\n function _setAdmin(address newAdmin) private {\n require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n */\n function _changeAdmin(address newAdmin) internal {\n emit AdminChanged(_getAdmin(), newAdmin);\n _setAdmin(newAdmin);\n }\n\n /**\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n */\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n /**\n * @dev Emitted when the beacon is upgraded.\n */\n event BeaconUpgraded(address indexed beacon);\n\n /**\n * @dev Returns the current beacon.\n */\n function _getBeacon() internal view returns (address) {\n return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;\n }\n\n /**\n * @dev Stores a new beacon in the EIP1967 beacon slot.\n */\n function _setBeacon(address newBeacon) private {\n require(\n AddressUpgradeable.isContract(newBeacon),\n \"ERC1967: new beacon is not a contract\"\n );\n require(\n AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),\n \"ERC1967: beacon implementation is not a contract\"\n );\n StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n }\n\n /*\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\n require(AddressUpgradeable.isContract(target), \"Address: delegate call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return _verifyCallResult(success, returndata, \"Address: low-level delegate call failed\");\n }\n\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n uint256[50] private __gap;\n}\n"
|
|
56
56
|
},
|
|
57
|
-
"@openzeppelin/contracts-upgradeable/utils/
|
|
58
|
-
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev
|
|
57
|
+
"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
|
|
58
|
+
"content": "// SPDX-License-Identifier: MIT\n\n// solhint-disable-next-line compiler-version\npragma solidity ^0.8.0;\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n */\nabstract contract Initializable {\n\n /**\n * @dev Indicates that the contract has been initialized.\n */\n bool private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Modifier to protect an initializer function from being invoked twice.\n */\n modifier initializer() {\n require(_initializing || !_initialized, \"Initializable: contract is already initialized\");\n\n bool isTopLevelCall = !_initializing;\n if (isTopLevelCall) {\n _initializing = true;\n _initialized = true;\n }\n\n _;\n\n if (isTopLevelCall) {\n _initializing = false;\n }\n }\n}\n"
|
|
59
59
|
},
|
|
60
60
|
"@openzeppelin/contracts-upgradeable/proxy/beacon/IBeaconUpgradeable.sol": {
|
|
61
61
|
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeaconUpgradeable {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n"
|
|
62
62
|
},
|
|
63
|
+
"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": {
|
|
64
|
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize, which returns 0 for contracts in\n // construction, since the code is only stored at the end of the\n // constructor execution.\n\n uint256 size;\n // solhint-disable-next-line no-inline-assembly\n assembly { size := extcodesize(account) }\n return size > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\n (bool success, ) = recipient.call{ value: amount }(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain`call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.call{ value: value }(data);\n return _verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.staticcall(data);\n return _verifyCallResult(success, returndata, errorMessage);\n }\n\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n"
|
|
65
|
+
},
|
|
63
66
|
"@openzeppelin/contracts-upgradeable/utils/StorageSlotUpgradeable.sol": {
|
|
64
67
|
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlotUpgradeable {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n}\n"
|
|
65
68
|
},
|
|
66
69
|
"contracts/test/RenamedRetyped.sol": {
|
|
67
70
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.2;\n\ncontract RenameV1 {\n uint x;\n}\n\ncontract RenameV2 {\n /// @custom:oz-renamed-from x\n uint y;\n}\n\ncontract RetypeV1 {\n bool x;\n}\n\ncontract RetypeV2 {\n /// @dev a retyped variable\n /// @custom:oz-retyped-from bool\n uint8 x;\n}\n\ncontract WronglyReportedRetypeV3 {\n /// @custom:oz-retyped-from address\n uint8 x;\n}\n\ncontract MissmatchingTypeRetypeV4 {\n /// @custom:oz-retyped-from bool\n bytes32 x;\n}\n\ncontract ConfusingRetypeV1 {\n address y;\n bool x;\n}\n\ncontract ConfusingRetypeV2 {\n address y;\n /// @custom:oz-retyped-from address\n uint8 x;\n}\n\ncontract NonHardcodedRetypeV1 {\n address a;\n}\n\ncontract NonHardcodedRetypeV2 {\n /// @custom:oz-retyped-from address\n bytes20 a;\n}\n\ncontract LayoutChangeV1 {\n bool a;\n bool b;\n}\n\ncontract LayoutChangeV2 {\n /// @custom:oz-retyped-from bool\n uint16 a;\n\n /// @custom:oz-retyped-from bool\n uint8 b;\n}"
|
|
68
71
|
},
|
|
72
|
+
"contracts/test/RetypeFromContract.sol": {
|
|
73
|
+
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.2;\n\ninterface CustomInterface {}\ncontract CustomContract {}\n\ninterface CustomInterface2 {}\ncontract CustomContract2 {}\n\ncontract RetypeContractToUint160V1 {\n CustomInterface a;\n CustomContract b;\n}\n\ncontract RetypeContractToUint160V2 {\n /// @custom:oz-retyped-from CustomInterface\n uint160 a;\n\n /// @custom:oz-retyped-from CustomContract\n uint160 b;\n}\n\ncontract RetypeUint160ToContractV1 {\n uint160 a;\n uint160 b;\n}\n\ncontract RetypeUint160ToContractV2 {\n /// @custom:oz-retyped-from uint160\n CustomInterface private a;\n\n /// @custom:oz-retyped-from uint160\n CustomContract private b;\n}\n\ncontract RetypeContractToUint160MappingV1 {\n mapping(uint8 => CustomInterface) a;\n mapping(uint8 => CustomContract) b;\n mapping(CustomInterface => CustomInterface) c;\n mapping(CustomContract => CustomContract) d;\n}\n\ncontract RetypeContractToUint160MappingV2 {\n /// @custom:oz-retyped-from mapping(uint8 => CustomInterface)\n mapping(uint8 => uint160) a;\n\n /// @custom:oz-retyped-from mapping(uint8 => CustomContract)\n mapping(uint8 => uint160) b;\n\n /// @custom:oz-retyped-from mapping(CustomInterface => CustomInterface)\n mapping(uint160 => uint160) c;\n\n /// @custom:oz-retyped-from mapping(CustomContract => CustomContract)\n mapping(uint160 => uint160) d;\n}\n\ncontract RetypeUint160ToContractMappingV1 {\n mapping(uint8 => uint160) a;\n mapping(uint8 => uint160) b;\n mapping(uint160 => uint160) c;\n mapping(uint160 => uint160) d;\n}\n\ncontract RetypeUint160ToContractMappingV2 {\n /// @custom:oz-retyped-from mapping(uint8 => uint160)\n mapping(uint8 => CustomInterface) a;\n\n /// @custom:oz-retyped-from mapping(uint8 => uint160)\n mapping(uint8 => CustomContract) b;\n\n /// @custom:oz-retyped-from mapping(uint160 => uint160)\n mapping(CustomInterface => CustomInterface) c;\n\n /// @custom:oz-retyped-from mapping(uint160 => uint160)\n mapping(CustomContract => CustomContract) d;\n}\n\ncontract ImplicitRetypeV1 {\n CustomInterface a;\n CustomContract b;\n\n address c;\n address d;\n\n CustomInterface e;\n CustomInterface f;\n\n CustomContract g;\n CustomContract h;\n}\n\ncontract ImplicitRetypeV2 {\n address a;\n address b;\n\n CustomInterface c;\n CustomContract d;\n\n CustomInterface2 e;\n CustomContract f;\n\n CustomContract2 g;\n CustomInterface h;\n}\n\ncontract ImplicitRetypeMappingV1 {\n mapping(uint8 => CustomInterface) a;\n mapping(uint8 => CustomContract) b;\n\n mapping(uint8 => address) c;\n mapping(uint8 => address) d;\n\n mapping(uint8 => CustomInterface) e;\n mapping(uint8 => CustomInterface) f;\n\n mapping(uint8 => CustomContract) g;\n mapping(uint8 => CustomContract) h;\n}\n\ncontract ImplicitRetypeMappingV2 {\n mapping(uint8 => address) a;\n mapping(uint8 => address) b;\n\n mapping(uint8 => CustomInterface) c;\n mapping(uint8 => CustomContract) d;\n\n mapping(uint8 => CustomInterface2) e;\n mapping(uint8 => CustomContract) f;\n\n mapping(uint8 => CustomContract2) g;\n mapping(uint8 => CustomInterface) h;\n}\n\nstruct StructUint256 {\n uint256 a;\n uint256 b;\n}\n\ncontract RetypeStructV1 {\n StructUint256 x;\n}\n\ncontract RetypeStructV2 {\n /// @custom:oz-retyped-from StructUint256\n uint256[2] x;\n}\n\ncontract RetypeStructV2Bad {\n /// @custom:oz-retyped-from StructUint256\n uint256[3] x;\n}\n\nenum MyEnums { ONE, TWO }\n\ncontract RetypeEnumV1 {\n MyEnums x;\n}\n\ncontract RetypeEnumV2 {\n /// @custom:oz-retyped-from MyEnums\n uint8 x;\n}\n\ncontract RetypeEnumV2Bad {\n /// @custom:oz-retyped-from MyEnums\n uint16 x;\n}"
|
|
74
|
+
},
|
|
69
75
|
"contracts/test/Standalone.sol": {
|
|
70
76
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.2;\n\ncontract StandaloneV1 {\n uint a;\n string b;\n\n function extremelyUnsafe(address target, bytes memory data) public {\n (bool ok, ) = target.delegatecall(data);\n require(ok);\n }\n}\n\ncontract StandaloneV2Good {\n uint a;\n string b;\n uint c;\n}\n\ncontract StandaloneV2Bad {\n uint x;\n uint a;\n string b;\n}\n\ncontract StandaloneRenameV1 {\n uint x;\n}\n\ncontract StandaloneRenameV2 {\n /// @custom:oz-renamed-from x\n uint y;\n}\n\ncontract StandaloneRenameV3 is StandaloneRenameV2 {\n uint z;\n}"
|
|
71
77
|
},
|
|
@@ -74,11 +74,13 @@ export declare class StorageLayoutComparator {
|
|
|
74
74
|
private layoutLevenshtein;
|
|
75
75
|
getVisibilityChange(original: ParsedTypeDetailed, updated: ParsedTypeDetailed): TypeChange | undefined;
|
|
76
76
|
getFieldChange<F extends StorageField>(original: F, updated: F): StorageFieldChange<F> | undefined;
|
|
77
|
+
private isRetypedFromOriginal;
|
|
77
78
|
getLayoutChange(original: StorageField, updated: StorageField): LayoutChange | undefined;
|
|
78
79
|
getTypeChange(original: ParsedTypeDetailed, updated: ParsedTypeDetailed, { allowAppend }: {
|
|
79
80
|
allowAppend: boolean;
|
|
80
81
|
}): TypeChange | undefined;
|
|
81
82
|
private uncachedGetTypeChange;
|
|
82
83
|
}
|
|
84
|
+
export declare function stripContractSubstrings(label?: string): string | undefined;
|
|
83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@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StorageLayoutComparator = exports.storageFieldEnd = exports.storageFieldBegin = void 0;
|
|
3
|
+
exports.stripContractSubstrings = exports.StorageLayoutComparator = exports.storageFieldEnd = exports.storageFieldBegin = void 0;
|
|
4
4
|
const levenshtein_1 = require("../levenshtein");
|
|
5
5
|
const layout_1 = require("./layout");
|
|
6
6
|
const error_1 = require("../error");
|
|
@@ -100,8 +100,8 @@ class StorageLayoutComparator {
|
|
|
100
100
|
original.label !== updated.renamedFrom &&
|
|
101
101
|
(updated.label !== original.label ||
|
|
102
102
|
(updated.renamedFrom !== undefined && updated.renamedFrom !== original.renamedFrom));
|
|
103
|
-
const
|
|
104
|
-
|
|
103
|
+
const typeChange = !this.isRetypedFromOriginal(original, updated) &&
|
|
104
|
+
this.getTypeChange(original.type, updated.type, { allowAppend: false });
|
|
105
105
|
const layoutChange = this.getLayoutChange(original, updated);
|
|
106
106
|
if (updated.retypedFrom && layoutChange && (!layoutChange.uncertain || !layoutChange.knownCompatible)) {
|
|
107
107
|
return { kind: 'layoutchange', original, updated, change: layoutChange, cost: LAYOUTCHANGE_COST };
|
|
@@ -129,6 +129,11 @@ class StorageLayoutComparator {
|
|
|
129
129
|
return { kind: 'layoutchange', original, updated, change: layoutChange, cost: LAYOUTCHANGE_COST };
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
+
isRetypedFromOriginal(original, updated) {
|
|
133
|
+
const originalLabel = stripContractSubstrings(original.type.item.label);
|
|
134
|
+
const updatedLabel = stripContractSubstrings(updated.retypedFrom?.trim());
|
|
135
|
+
return originalLabel === updatedLabel;
|
|
136
|
+
}
|
|
132
137
|
getLayoutChange(original, updated) {
|
|
133
138
|
if ((0, layout_1.hasLayout)(original) && (0, layout_1.hasLayout)(updated)) {
|
|
134
139
|
const change = (from, to) => (from === to ? undefined : { from, to });
|
|
@@ -167,7 +172,13 @@ class StorageLayoutComparator {
|
|
|
167
172
|
if (updated.head.startsWith('t_function')) {
|
|
168
173
|
return this.getVisibilityChange(original, updated);
|
|
169
174
|
}
|
|
170
|
-
if (original.head
|
|
175
|
+
if ((original.head === 't_contract' && updated.head === 't_address') ||
|
|
176
|
+
(original.head === 't_address' && updated.head === 't_contract')) {
|
|
177
|
+
// changing contract to address or address to contract
|
|
178
|
+
// equivalent to just addresses
|
|
179
|
+
return undefined;
|
|
180
|
+
}
|
|
181
|
+
if (normalizeMemoryPointer(original.head) !== normalizeMemoryPointer(updated.head)) {
|
|
171
182
|
return { kind: 'obvious mismatch', original, updated };
|
|
172
183
|
}
|
|
173
184
|
if (original.args === undefined || updated.args === undefined) {
|
|
@@ -177,6 +188,7 @@ class StorageLayoutComparator {
|
|
|
177
188
|
}
|
|
178
189
|
switch (original.head) {
|
|
179
190
|
case 't_contract':
|
|
191
|
+
// changing contract to contract
|
|
180
192
|
// no storage layout errors can be introduced here since it is just an address
|
|
181
193
|
return undefined;
|
|
182
194
|
case 't_struct': {
|
|
@@ -299,4 +311,17 @@ exports.StorageLayoutComparator = StorageLayoutComparator;
|
|
|
299
311
|
function enumSize(memberCount) {
|
|
300
312
|
return Math.ceil(Math.log2(Math.max(2, memberCount)) / 8);
|
|
301
313
|
}
|
|
314
|
+
function stripContractSubstrings(label) {
|
|
315
|
+
if (label !== undefined) {
|
|
316
|
+
return label.replace(/\b(contract|struct|enum) /g, '');
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
exports.stripContractSubstrings = stripContractSubstrings;
|
|
320
|
+
/**
|
|
321
|
+
* Some versions of Solidity use type ids with _memory_ptr suffix while other versions use _memory suffix.
|
|
322
|
+
* Normalize these for type comparison purposes only.
|
|
323
|
+
*/
|
|
324
|
+
function normalizeMemoryPointer(typeIdentifier) {
|
|
325
|
+
return typeIdentifier.replace(/_memory_ptr\b/g, '_memory');
|
|
326
|
+
}
|
|
302
327
|
//# sourceMappingURL=compare.js.map
|
|
@@ -1 +1 @@
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EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;SACjD;IACH,CAAC;CACF;AAlTD,0DAkTC;AAED,SAAS,QAAQ,CAAC,WAAmB;IACnC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5D,CAAC;AAED,SAAgB,uBAAuB,CAAC,KAAc;IACpD,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,OAAO,KAAK,CAAC,OAAO,CAAC,4BAA4B,EAAE,EAAE,CAAC,CAAC;KACxD;AACH,CAAC;AAJD,0DAIC;AAED;;;GAGG;AACH,SAAS,sBAAsB,CAAC,cAAsB;IACpD,OAAO,cAAc,CAAC,OAAO,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report-retype-from-contract.test.d.ts","sourceRoot":"","sources":["../../src/storage/report-retype-from-contract.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ava_1 = __importDefault(require("ava"));
|
|
7
|
+
const utils_1 = require("solidity-ast/utils");
|
|
8
|
+
const hardhat_1 = require("hardhat");
|
|
9
|
+
const ast_dereferencer_1 = require("../ast-dereferencer");
|
|
10
|
+
const extract_1 = require("./extract");
|
|
11
|
+
const compare_1 = require("./compare");
|
|
12
|
+
const layout_1 = require("./layout");
|
|
13
|
+
const _1 = require(".");
|
|
14
|
+
const test = ava_1.default;
|
|
15
|
+
const dummyDecodeSrc = () => 'file.sol:1';
|
|
16
|
+
const testContracts = [
|
|
17
|
+
'contracts/test/RetypeFromContract.sol:RetypeContractToUint160V1',
|
|
18
|
+
'contracts/test/RetypeFromContract.sol:RetypeContractToUint160V2',
|
|
19
|
+
'contracts/test/RetypeFromContract.sol:RetypeUint160ToContractV1',
|
|
20
|
+
'contracts/test/RetypeFromContract.sol:RetypeUint160ToContractV2',
|
|
21
|
+
'contracts/test/RetypeFromContract.sol:RetypeContractToUint160MappingV1',
|
|
22
|
+
'contracts/test/RetypeFromContract.sol:RetypeContractToUint160MappingV2',
|
|
23
|
+
'contracts/test/RetypeFromContract.sol:RetypeUint160ToContractMappingV1',
|
|
24
|
+
'contracts/test/RetypeFromContract.sol:RetypeUint160ToContractMappingV2',
|
|
25
|
+
'contracts/test/RetypeFromContract.sol:ImplicitRetypeV1',
|
|
26
|
+
'contracts/test/RetypeFromContract.sol:ImplicitRetypeV2',
|
|
27
|
+
'contracts/test/RetypeFromContract.sol:ImplicitRetypeMappingV1',
|
|
28
|
+
'contracts/test/RetypeFromContract.sol:ImplicitRetypeMappingV2',
|
|
29
|
+
'contracts/test/RetypeFromContract.sol:RetypeStructV1',
|
|
30
|
+
'contracts/test/RetypeFromContract.sol:RetypeStructV2',
|
|
31
|
+
'contracts/test/RetypeFromContract.sol:RetypeStructV2Bad',
|
|
32
|
+
'contracts/test/RetypeFromContract.sol:RetypeEnumV1',
|
|
33
|
+
'contracts/test/RetypeFromContract.sol:RetypeEnumV2',
|
|
34
|
+
'contracts/test/RetypeFromContract.sol:RetypeEnumV2Bad',
|
|
35
|
+
];
|
|
36
|
+
test.before(async (t) => {
|
|
37
|
+
const contracts = {};
|
|
38
|
+
const deref = {};
|
|
39
|
+
const storageLayout = {};
|
|
40
|
+
for (const contract of testContracts) {
|
|
41
|
+
const buildInfo = await hardhat_1.artifacts.getBuildInfo(contract);
|
|
42
|
+
if (buildInfo === undefined) {
|
|
43
|
+
throw new Error(`Build info not found for contract ${contract}`);
|
|
44
|
+
}
|
|
45
|
+
const solcOutput = buildInfo.output;
|
|
46
|
+
for (const def of (0, utils_1.findAll)('ContractDefinition', solcOutput.sources['contracts/test/RetypeFromContract.sol'].ast)) {
|
|
47
|
+
contracts[def.name] = def;
|
|
48
|
+
deref[def.name] = (0, ast_dereferencer_1.astDereferencer)(solcOutput);
|
|
49
|
+
storageLayout[def.name] = solcOutput.contracts['contracts/test/RetypeFromContract.sol'][def.name].storageLayout;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
t.context.extractStorageLayout = name => (0, extract_1.extractStorageLayout)(contracts[name], dummyDecodeSrc, deref[name], storageLayout[name]);
|
|
53
|
+
});
|
|
54
|
+
function getReport(original, updated) {
|
|
55
|
+
const originalDetailed = (0, layout_1.getDetailedLayout)(original);
|
|
56
|
+
const updatedDetailed = (0, layout_1.getDetailedLayout)(updated);
|
|
57
|
+
const comparator = new compare_1.StorageLayoutComparator();
|
|
58
|
+
return comparator.compareLayouts(originalDetailed, updatedDetailed);
|
|
59
|
+
}
|
|
60
|
+
test('retype contract to uint160', t => {
|
|
61
|
+
const v1 = t.context.extractStorageLayout('RetypeContractToUint160V1');
|
|
62
|
+
const v2 = t.context.extractStorageLayout('RetypeContractToUint160V2');
|
|
63
|
+
const report = getReport(v1, v2);
|
|
64
|
+
t.true(report.ok, report.explain());
|
|
65
|
+
});
|
|
66
|
+
test('retype uint160 to contract', t => {
|
|
67
|
+
const v1 = t.context.extractStorageLayout('RetypeUint160ToContractV1');
|
|
68
|
+
const v2 = t.context.extractStorageLayout('RetypeUint160ToContractV2');
|
|
69
|
+
const report = getReport(v1, v2);
|
|
70
|
+
t.true(report.ok, report.explain());
|
|
71
|
+
});
|
|
72
|
+
test('retype contract to uint160 mapping', t => {
|
|
73
|
+
const v1 = t.context.extractStorageLayout('RetypeContractToUint160MappingV1');
|
|
74
|
+
const v2 = t.context.extractStorageLayout('RetypeContractToUint160MappingV2');
|
|
75
|
+
const report = getReport(v1, v2);
|
|
76
|
+
t.true(report.ok, report.explain());
|
|
77
|
+
});
|
|
78
|
+
test('retype uint160 to contract mapping', t => {
|
|
79
|
+
const v1 = t.context.extractStorageLayout('RetypeUint160ToContractMappingV1');
|
|
80
|
+
const v2 = t.context.extractStorageLayout('RetypeUint160ToContractMappingV2');
|
|
81
|
+
const report = getReport(v1, v2);
|
|
82
|
+
t.true(report.ok, report.explain());
|
|
83
|
+
});
|
|
84
|
+
test('implicit retype', t => {
|
|
85
|
+
const v1 = t.context.extractStorageLayout('ImplicitRetypeV1');
|
|
86
|
+
const v2 = t.context.extractStorageLayout('ImplicitRetypeV2');
|
|
87
|
+
const report = getReport(v1, v2);
|
|
88
|
+
t.true(report.ok, report.explain());
|
|
89
|
+
});
|
|
90
|
+
test('implicit retype mapping', t => {
|
|
91
|
+
const v1 = t.context.extractStorageLayout('ImplicitRetypeMappingV1');
|
|
92
|
+
const v2 = t.context.extractStorageLayout('ImplicitRetypeMappingV2');
|
|
93
|
+
const report = getReport(v1, v2);
|
|
94
|
+
t.true(report.ok, report.explain());
|
|
95
|
+
});
|
|
96
|
+
test('strip contract substrings', t => {
|
|
97
|
+
t.is((0, compare_1.stripContractSubstrings)(undefined), undefined);
|
|
98
|
+
t.is((0, compare_1.stripContractSubstrings)('address'), 'address');
|
|
99
|
+
t.is((0, compare_1.stripContractSubstrings)('CustomContract'), 'CustomContract');
|
|
100
|
+
t.is((0, compare_1.stripContractSubstrings)('contract CustomContract'), 'CustomContract');
|
|
101
|
+
t.is((0, compare_1.stripContractSubstrings)('mapping(uint8 => CustomContract)'), 'mapping(uint8 => CustomContract)');
|
|
102
|
+
t.is((0, compare_1.stripContractSubstrings)('mapping(uint8 => contract CustomContract)'), 'mapping(uint8 => CustomContract)');
|
|
103
|
+
t.is((0, compare_1.stripContractSubstrings)('mapping(contract CustomContract => uint8)'), 'mapping(CustomContract => uint8)');
|
|
104
|
+
t.is((0, compare_1.stripContractSubstrings)('mapping(contract A => contract B)'), 'mapping(A => B)');
|
|
105
|
+
t.is((0, compare_1.stripContractSubstrings)('mapping(Substringcontract => address)'), 'mapping(Substringcontract => address)');
|
|
106
|
+
t.is((0, compare_1.stripContractSubstrings)('mapping(contract Substringcontract => address)'), 'mapping(Substringcontract => address)');
|
|
107
|
+
t.is((0, compare_1.stripContractSubstrings)('Mystruct'), 'Mystruct');
|
|
108
|
+
t.is((0, compare_1.stripContractSubstrings)('struct Mystruct'), 'Mystruct');
|
|
109
|
+
t.is((0, compare_1.stripContractSubstrings)('Myenum'), 'Myenum');
|
|
110
|
+
t.is((0, compare_1.stripContractSubstrings)('enum Myenum'), 'Myenum');
|
|
111
|
+
});
|
|
112
|
+
test('retype from struct', t => {
|
|
113
|
+
const v1 = t.context.extractStorageLayout('RetypeStructV1');
|
|
114
|
+
const v2 = t.context.extractStorageLayout('RetypeStructV2');
|
|
115
|
+
const report = getReport(v1, v2);
|
|
116
|
+
t.true(report.ok, report.explain());
|
|
117
|
+
});
|
|
118
|
+
test('bad retype from struct', t => {
|
|
119
|
+
const v1 = t.context.extractStorageLayout('RetypeStructV1');
|
|
120
|
+
const v2 = t.context.extractStorageLayout('RetypeStructV2Bad');
|
|
121
|
+
t.like((0, _1.getStorageUpgradeErrors)(v1, v2), {
|
|
122
|
+
length: 1,
|
|
123
|
+
0: {
|
|
124
|
+
kind: 'layoutchange',
|
|
125
|
+
original: { label: 'x' },
|
|
126
|
+
updated: { label: 'x' },
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
test('retype from enum', t => {
|
|
131
|
+
const v1 = t.context.extractStorageLayout('RetypeEnumV1');
|
|
132
|
+
const v2 = t.context.extractStorageLayout('RetypeEnumV2');
|
|
133
|
+
const report = getReport(v1, v2);
|
|
134
|
+
t.true(report.ok, report.explain());
|
|
135
|
+
});
|
|
136
|
+
test('bad retype from enum', t => {
|
|
137
|
+
const v1 = t.context.extractStorageLayout('RetypeEnumV1');
|
|
138
|
+
const v2 = t.context.extractStorageLayout('RetypeEnumV2Bad');
|
|
139
|
+
t.like((0, _1.getStorageUpgradeErrors)(v1, v2), {
|
|
140
|
+
length: 1,
|
|
141
|
+
0: {
|
|
142
|
+
kind: 'layoutchange',
|
|
143
|
+
original: { label: 'x' },
|
|
144
|
+
updated: { label: 'x' },
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
//# sourceMappingURL=report-retype-from-contract.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report-retype-from-contract.test.js","sourceRoot":"","sources":["../../src/storage/report-retype-from-contract.test.ts"],"names":[],"mappings":";;;;;AAAA,8CAAoC;AAEpC,8CAA8D;AAC9D,qCAAoC;AACpC,0DAAsD;AACtD,uCAAiD;AACjD,uCAA6E;AAC7E,qCAA4D;AAC5D,wBAA4C;AAM5C,MAAM,IAAI,GAAG,aAAwB,CAAC;AAEtC,MAAM,cAAc,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC;AAC1C,MAAM,aAAa,GAAG;IACpB,iEAAiE;IACjE,iEAAiE;IACjE,iEAAiE;IACjE,iEAAiE;IACjE,wEAAwE;IACxE,wEAAwE;IACxE,wEAAwE;IACxE,wEAAwE;IACxE,wDAAwD;IACxD,wDAAwD;IACxD,+DAA+D;IAC/D,+DAA+D;IAC/D,sDAAsD;IACtD,sDAAsD;IACtD,yDAAyD;IACzD,oDAAoD;IACpD,oDAAoD;IACpD,uDAAuD;CACxD,CAAC;AAEF,IAAI,CAAC,MAAM,CAAC,KAAK,EAAC,CAAC,EAAC,EAAE;IACpB,MAAM,SAAS,GAAuC,EAAE,CAAC;IACzD,MAAM,KAAK,GAAoC,EAAE,CAAC;IAClD,MAAM,aAAa,GAAkC,EAAE,CAAC;IACxD,KAAK,MAAM,QAAQ,IAAI,aAAa,EAAE;QACpC,MAAM,SAAS,GAAG,MAAM,mBAAS,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QACzD,IAAI,SAAS,KAAK,SAAS,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,qCAAqC,QAAQ,EAAE,CAAC,CAAC;S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C1D,MAAM,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;IAC7D,CAAC,CAAC,IAAI,CAAC,IAAA,0BAAuB,EAAC,EAAE,EAAE,EAAE,CAAC,EAAE;QACtC,MAAM,EAAE,CAAC;QACT,CAAC,EAAE;YACD,IAAI,EAAE,cAAc;YACpB,QAAQ,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE;YACxB,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE;SACxB;KACF,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-memory-0.5.test.d.ts","sourceRoot":"","sources":["../src/storage-memory-0.5.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ava_1 = __importDefault(require("ava"));
|
|
7
|
+
const utils_1 = require("solidity-ast/utils");
|
|
8
|
+
const hardhat_1 = require("hardhat");
|
|
9
|
+
const ast_dereferencer_1 = require("./ast-dereferencer");
|
|
10
|
+
const storage_1 = require("./storage");
|
|
11
|
+
const extract_1 = require("./storage/extract");
|
|
12
|
+
const stabilize_layout_1 = require("./utils/stabilize-layout");
|
|
13
|
+
const test = ava_1.default;
|
|
14
|
+
test.before(async (t) => {
|
|
15
|
+
const buildInfoCache = {};
|
|
16
|
+
t.context.extractStorageLayout = async (contractFile, contractName, withLayout = true) => {
|
|
17
|
+
const expectedContract = contractName ?? contractFile;
|
|
18
|
+
const [file] = contractFile.split('_');
|
|
19
|
+
const source = `contracts/test/${file}.sol`;
|
|
20
|
+
const buildInfo = (buildInfoCache[source] ?? (buildInfoCache[source] = await hardhat_1.artifacts.getBuildInfo(`${source}:${expectedContract}`)));
|
|
21
|
+
if (buildInfo === undefined) {
|
|
22
|
+
throw new Error(`Build info for ${source} not found`);
|
|
23
|
+
}
|
|
24
|
+
const solcOutput = buildInfo.output;
|
|
25
|
+
for (const def of (0, utils_1.findAll)('ContractDefinition', solcOutput.sources[source].ast)) {
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
27
|
+
const layout = solcOutput.contracts[source][def.name].storageLayout;
|
|
28
|
+
if (def.name === expectedContract) {
|
|
29
|
+
return (0, extract_1.extractStorageLayout)(def, dummyDecodeSrc, (0, ast_dereferencer_1.astDereferencer)(solcOutput), withLayout ? layout : undefined);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
throw new Error(`Contract ${expectedContract} not found in ${source}`);
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
const dummyDecodeSrc = () => 'file.sol:1';
|
|
36
|
+
test('memory 0.5.16', async (t) => {
|
|
37
|
+
const layout = await t.context.extractStorageLayout('Memory05');
|
|
38
|
+
t.snapshot((0, stabilize_layout_1.stabilizeStorageLayout)(layout));
|
|
39
|
+
});
|
|
40
|
+
test('memory 0.8.9', async (t) => {
|
|
41
|
+
const layout = await t.context.extractStorageLayout('Memory08');
|
|
42
|
+
t.snapshot((0, stabilize_layout_1.stabilizeStorageLayout)(layout));
|
|
43
|
+
});
|
|
44
|
+
test('memory - upgrade from 0.5.16 to 0.8.9', async (t) => {
|
|
45
|
+
const v1 = await t.context.extractStorageLayout('Memory05');
|
|
46
|
+
const v2 = await t.context.extractStorageLayout('Memory08');
|
|
47
|
+
const comparison = (0, storage_1.getStorageUpgradeErrors)(v1, v2);
|
|
48
|
+
t.deepEqual(comparison, []);
|
|
49
|
+
});
|
|
50
|
+
test('memory - bad upgrade from 0.5.16 to 0.8.9', async (t) => {
|
|
51
|
+
const v1 = await t.context.extractStorageLayout('Memory05');
|
|
52
|
+
const v2 = await t.context.extractStorageLayout('Memory08', 'Memory08Bad');
|
|
53
|
+
const comparison = (0, storage_1.getStorageUpgradeErrors)(v1, v2);
|
|
54
|
+
t.like(comparison, {
|
|
55
|
+
length: 2,
|
|
56
|
+
0: {
|
|
57
|
+
kind: 'typechange',
|
|
58
|
+
change: {
|
|
59
|
+
kind: 'mapping key',
|
|
60
|
+
},
|
|
61
|
+
original: { label: 'a' },
|
|
62
|
+
updated: { label: 'a' },
|
|
63
|
+
},
|
|
64
|
+
1: {
|
|
65
|
+
kind: 'typechange',
|
|
66
|
+
change: {
|
|
67
|
+
kind: 'mapping key',
|
|
68
|
+
},
|
|
69
|
+
original: { label: 'b' },
|
|
70
|
+
updated: { label: 'b' },
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=storage-memory-0.5.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-memory-0.5.test.js","sourceRoot":"","sources":["../src/storage-memory-0.5.test.ts"],"names":[],"mappings":";;;;;AAAA,8CAAoC;AACpC,8CAA6C;AAC7C,qCAAoC;AAGpC,yDAAqD;AACrD,uCAAoD;AACpD,+CAAyD;AAEzD,+DAAkE;AAUlE,MAAM,IAAI,GAAG,aAAwB,CAAC;AAEtC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAC,CAAC,EAAC,EAAE;IACpB,MAAM,cAAc,GAA0C,EAAE,CAAC;IACjE,CAAC,CAAC,OAAO,CAAC,oBAAoB,GAAG,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,GAAG,IAAI,EAAE,EAAE;QACvF,MAAM,gBAAgB,GAAG,YAAY,IAAI,YAAY,CAAC;QAEtD,MAAM,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACvC,MAAM,MAAM,GAAG,kBAAkB,IAAI,MAAM,CAAC;QAC5C,MAAM,SAAS,GAAG,CAAC,cAAc,CAAC,MAAM,MAArB,cAAc,CAAC,MA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,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE;YACxB,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE;SACxB;KACF,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openzeppelin/upgrades-core",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": "https://github.com/OpenZeppelin/openzeppelin-upgrades/tree/master/packages/core",
|
|
6
6
|
"license": "MIT",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"proper-lockfile": "^4.1.1",
|
|
59
59
|
"solidity-ast": "^0.4.15"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "d551c6e8775925d2036044c6399d01007a191795"
|
|
62
62
|
}
|
package/src/storage/compare.ts
CHANGED
|
@@ -168,8 +168,9 @@ export class StorageLayoutComparator {
|
|
|
168
168
|
original.label !== updated.renamedFrom &&
|
|
169
169
|
(updated.label !== original.label ||
|
|
170
170
|
(updated.renamedFrom !== undefined && updated.renamedFrom !== original.renamedFrom));
|
|
171
|
-
const
|
|
172
|
-
|
|
171
|
+
const typeChange =
|
|
172
|
+
!this.isRetypedFromOriginal(original, updated) &&
|
|
173
|
+
this.getTypeChange(original.type, updated.type, { allowAppend: false });
|
|
173
174
|
const layoutChange = this.getLayoutChange(original, updated);
|
|
174
175
|
|
|
175
176
|
if (updated.retypedFrom && layoutChange && (!layoutChange.uncertain || !layoutChange.knownCompatible)) {
|
|
@@ -193,6 +194,13 @@ export class StorageLayoutComparator {
|
|
|
193
194
|
}
|
|
194
195
|
}
|
|
195
196
|
|
|
197
|
+
private isRetypedFromOriginal(original: StorageField, updated: StorageField) {
|
|
198
|
+
const originalLabel = stripContractSubstrings(original.type.item.label);
|
|
199
|
+
const updatedLabel = stripContractSubstrings(updated.retypedFrom?.trim());
|
|
200
|
+
|
|
201
|
+
return originalLabel === updatedLabel;
|
|
202
|
+
}
|
|
203
|
+
|
|
196
204
|
getLayoutChange(original: StorageField, updated: StorageField): LayoutChange | undefined {
|
|
197
205
|
if (hasLayout(original) && hasLayout(updated)) {
|
|
198
206
|
const change = <T>(from: T, to: T) => (from === to ? undefined : { from, to });
|
|
@@ -244,7 +252,16 @@ export class StorageLayoutComparator {
|
|
|
244
252
|
return this.getVisibilityChange(original, updated);
|
|
245
253
|
}
|
|
246
254
|
|
|
247
|
-
if (
|
|
255
|
+
if (
|
|
256
|
+
(original.head === 't_contract' && updated.head === 't_address') ||
|
|
257
|
+
(original.head === 't_address' && updated.head === 't_contract')
|
|
258
|
+
) {
|
|
259
|
+
// changing contract to address or address to contract
|
|
260
|
+
// equivalent to just addresses
|
|
261
|
+
return undefined;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (normalizeMemoryPointer(original.head) !== normalizeMemoryPointer(updated.head)) {
|
|
248
265
|
return { kind: 'obvious mismatch', original, updated };
|
|
249
266
|
}
|
|
250
267
|
|
|
@@ -256,6 +273,7 @@ export class StorageLayoutComparator {
|
|
|
256
273
|
|
|
257
274
|
switch (original.head) {
|
|
258
275
|
case 't_contract':
|
|
276
|
+
// changing contract to contract
|
|
259
277
|
// no storage layout errors can be introduced here since it is just an address
|
|
260
278
|
return undefined;
|
|
261
279
|
|
|
@@ -389,3 +407,17 @@ export class StorageLayoutComparator {
|
|
|
389
407
|
function enumSize(memberCount: number): number {
|
|
390
408
|
return Math.ceil(Math.log2(Math.max(2, memberCount)) / 8);
|
|
391
409
|
}
|
|
410
|
+
|
|
411
|
+
export function stripContractSubstrings(label?: string) {
|
|
412
|
+
if (label !== undefined) {
|
|
413
|
+
return label.replace(/\b(contract|struct|enum) /g, '');
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Some versions of Solidity use type ids with _memory_ptr suffix while other versions use _memory suffix.
|
|
419
|
+
* Normalize these for type comparison purposes only.
|
|
420
|
+
*/
|
|
421
|
+
function normalizeMemoryPointer(typeIdentifier: string): string {
|
|
422
|
+
return typeIdentifier.replace(/_memory_ptr\b/g, '_memory');
|
|
423
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import _test, { TestFn } from 'ava';
|
|
2
|
+
import { ContractDefinition } from 'solidity-ast';
|
|
3
|
+
import { ASTDereferencer, findAll } from 'solidity-ast/utils';
|
|
4
|
+
import { artifacts } from 'hardhat';
|
|
5
|
+
import { astDereferencer } from '../ast-dereferencer';
|
|
6
|
+
import { extractStorageLayout } from './extract';
|
|
7
|
+
import { StorageLayoutComparator, stripContractSubstrings } from './compare';
|
|
8
|
+
import { StorageLayout, getDetailedLayout } from './layout';
|
|
9
|
+
import { getStorageUpgradeErrors } from '.';
|
|
10
|
+
|
|
11
|
+
interface Context {
|
|
12
|
+
extractStorageLayout: (contract: string) => ReturnType<typeof extractStorageLayout>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const test = _test as TestFn<Context>;
|
|
16
|
+
|
|
17
|
+
const dummyDecodeSrc = () => 'file.sol:1';
|
|
18
|
+
const testContracts = [
|
|
19
|
+
'contracts/test/RetypeFromContract.sol:RetypeContractToUint160V1',
|
|
20
|
+
'contracts/test/RetypeFromContract.sol:RetypeContractToUint160V2',
|
|
21
|
+
'contracts/test/RetypeFromContract.sol:RetypeUint160ToContractV1',
|
|
22
|
+
'contracts/test/RetypeFromContract.sol:RetypeUint160ToContractV2',
|
|
23
|
+
'contracts/test/RetypeFromContract.sol:RetypeContractToUint160MappingV1',
|
|
24
|
+
'contracts/test/RetypeFromContract.sol:RetypeContractToUint160MappingV2',
|
|
25
|
+
'contracts/test/RetypeFromContract.sol:RetypeUint160ToContractMappingV1',
|
|
26
|
+
'contracts/test/RetypeFromContract.sol:RetypeUint160ToContractMappingV2',
|
|
27
|
+
'contracts/test/RetypeFromContract.sol:ImplicitRetypeV1',
|
|
28
|
+
'contracts/test/RetypeFromContract.sol:ImplicitRetypeV2',
|
|
29
|
+
'contracts/test/RetypeFromContract.sol:ImplicitRetypeMappingV1',
|
|
30
|
+
'contracts/test/RetypeFromContract.sol:ImplicitRetypeMappingV2',
|
|
31
|
+
'contracts/test/RetypeFromContract.sol:RetypeStructV1',
|
|
32
|
+
'contracts/test/RetypeFromContract.sol:RetypeStructV2',
|
|
33
|
+
'contracts/test/RetypeFromContract.sol:RetypeStructV2Bad',
|
|
34
|
+
'contracts/test/RetypeFromContract.sol:RetypeEnumV1',
|
|
35
|
+
'contracts/test/RetypeFromContract.sol:RetypeEnumV2',
|
|
36
|
+
'contracts/test/RetypeFromContract.sol:RetypeEnumV2Bad',
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
test.before(async t => {
|
|
40
|
+
const contracts: Record<string, ContractDefinition> = {};
|
|
41
|
+
const deref: Record<string, ASTDereferencer> = {};
|
|
42
|
+
const storageLayout: Record<string, StorageLayout> = {};
|
|
43
|
+
for (const contract of testContracts) {
|
|
44
|
+
const buildInfo = await artifacts.getBuildInfo(contract);
|
|
45
|
+
if (buildInfo === undefined) {
|
|
46
|
+
throw new Error(`Build info not found for contract ${contract}`);
|
|
47
|
+
}
|
|
48
|
+
const solcOutput = buildInfo.output;
|
|
49
|
+
for (const def of findAll('ContractDefinition', solcOutput.sources['contracts/test/RetypeFromContract.sol'].ast)) {
|
|
50
|
+
contracts[def.name] = def;
|
|
51
|
+
deref[def.name] = astDereferencer(solcOutput);
|
|
52
|
+
storageLayout[def.name] = (
|
|
53
|
+
solcOutput.contracts['contracts/test/RetypeFromContract.sol'][def.name] as any
|
|
54
|
+
).storageLayout;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
t.context.extractStorageLayout = name =>
|
|
59
|
+
extractStorageLayout(contracts[name], dummyDecodeSrc, deref[name], storageLayout[name]);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
function getReport(original: StorageLayout, updated: StorageLayout) {
|
|
63
|
+
const originalDetailed = getDetailedLayout(original);
|
|
64
|
+
const updatedDetailed = getDetailedLayout(updated);
|
|
65
|
+
const comparator = new StorageLayoutComparator();
|
|
66
|
+
return comparator.compareLayouts(originalDetailed, updatedDetailed);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
test('retype contract to uint160', t => {
|
|
70
|
+
const v1 = t.context.extractStorageLayout('RetypeContractToUint160V1');
|
|
71
|
+
const v2 = t.context.extractStorageLayout('RetypeContractToUint160V2');
|
|
72
|
+
const report = getReport(v1, v2);
|
|
73
|
+
t.true(report.ok, report.explain());
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('retype uint160 to contract', t => {
|
|
77
|
+
const v1 = t.context.extractStorageLayout('RetypeUint160ToContractV1');
|
|
78
|
+
const v2 = t.context.extractStorageLayout('RetypeUint160ToContractV2');
|
|
79
|
+
const report = getReport(v1, v2);
|
|
80
|
+
t.true(report.ok, report.explain());
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('retype contract to uint160 mapping', t => {
|
|
84
|
+
const v1 = t.context.extractStorageLayout('RetypeContractToUint160MappingV1');
|
|
85
|
+
const v2 = t.context.extractStorageLayout('RetypeContractToUint160MappingV2');
|
|
86
|
+
const report = getReport(v1, v2);
|
|
87
|
+
t.true(report.ok, report.explain());
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('retype uint160 to contract mapping', t => {
|
|
91
|
+
const v1 = t.context.extractStorageLayout('RetypeUint160ToContractMappingV1');
|
|
92
|
+
const v2 = t.context.extractStorageLayout('RetypeUint160ToContractMappingV2');
|
|
93
|
+
const report = getReport(v1, v2);
|
|
94
|
+
t.true(report.ok, report.explain());
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('implicit retype', t => {
|
|
98
|
+
const v1 = t.context.extractStorageLayout('ImplicitRetypeV1');
|
|
99
|
+
const v2 = t.context.extractStorageLayout('ImplicitRetypeV2');
|
|
100
|
+
const report = getReport(v1, v2);
|
|
101
|
+
t.true(report.ok, report.explain());
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test('implicit retype mapping', t => {
|
|
105
|
+
const v1 = t.context.extractStorageLayout('ImplicitRetypeMappingV1');
|
|
106
|
+
const v2 = t.context.extractStorageLayout('ImplicitRetypeMappingV2');
|
|
107
|
+
const report = getReport(v1, v2);
|
|
108
|
+
t.true(report.ok, report.explain());
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test('strip contract substrings', t => {
|
|
112
|
+
t.is(stripContractSubstrings(undefined), undefined);
|
|
113
|
+
t.is(stripContractSubstrings('address'), 'address');
|
|
114
|
+
t.is(stripContractSubstrings('CustomContract'), 'CustomContract');
|
|
115
|
+
t.is(stripContractSubstrings('contract CustomContract'), 'CustomContract');
|
|
116
|
+
t.is(stripContractSubstrings('mapping(uint8 => CustomContract)'), 'mapping(uint8 => CustomContract)');
|
|
117
|
+
t.is(stripContractSubstrings('mapping(uint8 => contract CustomContract)'), 'mapping(uint8 => CustomContract)');
|
|
118
|
+
t.is(stripContractSubstrings('mapping(contract CustomContract => uint8)'), 'mapping(CustomContract => uint8)');
|
|
119
|
+
t.is(stripContractSubstrings('mapping(contract A => contract B)'), 'mapping(A => B)');
|
|
120
|
+
t.is(stripContractSubstrings('mapping(Substringcontract => address)'), 'mapping(Substringcontract => address)');
|
|
121
|
+
t.is(
|
|
122
|
+
stripContractSubstrings('mapping(contract Substringcontract => address)'),
|
|
123
|
+
'mapping(Substringcontract => address)',
|
|
124
|
+
);
|
|
125
|
+
t.is(stripContractSubstrings('Mystruct'), 'Mystruct');
|
|
126
|
+
t.is(stripContractSubstrings('struct Mystruct'), 'Mystruct');
|
|
127
|
+
t.is(stripContractSubstrings('Myenum'), 'Myenum');
|
|
128
|
+
t.is(stripContractSubstrings('enum Myenum'), 'Myenum');
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test('retype from struct', t => {
|
|
132
|
+
const v1 = t.context.extractStorageLayout('RetypeStructV1');
|
|
133
|
+
const v2 = t.context.extractStorageLayout('RetypeStructV2');
|
|
134
|
+
const report = getReport(v1, v2);
|
|
135
|
+
t.true(report.ok, report.explain());
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test('bad retype from struct', t => {
|
|
139
|
+
const v1 = t.context.extractStorageLayout('RetypeStructV1');
|
|
140
|
+
const v2 = t.context.extractStorageLayout('RetypeStructV2Bad');
|
|
141
|
+
t.like(getStorageUpgradeErrors(v1, v2), {
|
|
142
|
+
length: 1,
|
|
143
|
+
0: {
|
|
144
|
+
kind: 'layoutchange',
|
|
145
|
+
original: { label: 'x' },
|
|
146
|
+
updated: { label: 'x' },
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
test('retype from enum', t => {
|
|
152
|
+
const v1 = t.context.extractStorageLayout('RetypeEnumV1');
|
|
153
|
+
const v2 = t.context.extractStorageLayout('RetypeEnumV2');
|
|
154
|
+
const report = getReport(v1, v2);
|
|
155
|
+
t.true(report.ok, report.explain());
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
test('bad retype from enum', t => {
|
|
159
|
+
const v1 = t.context.extractStorageLayout('RetypeEnumV1');
|
|
160
|
+
const v2 = t.context.extractStorageLayout('RetypeEnumV2Bad');
|
|
161
|
+
t.like(getStorageUpgradeErrors(v1, v2), {
|
|
162
|
+
length: 1,
|
|
163
|
+
0: {
|
|
164
|
+
kind: 'layoutchange',
|
|
165
|
+
original: { label: 'x' },
|
|
166
|
+
updated: { label: 'x' },
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import _test, { TestFn } from 'ava';
|
|
2
|
+
import { findAll } from 'solidity-ast/utils';
|
|
3
|
+
import { artifacts } from 'hardhat';
|
|
4
|
+
|
|
5
|
+
import { SolcOutput } from './solc-api';
|
|
6
|
+
import { astDereferencer } from './ast-dereferencer';
|
|
7
|
+
import { getStorageUpgradeErrors } from './storage';
|
|
8
|
+
import { extractStorageLayout } from './storage/extract';
|
|
9
|
+
import { BuildInfo } from 'hardhat/types';
|
|
10
|
+
import { stabilizeStorageLayout } from './utils/stabilize-layout';
|
|
11
|
+
|
|
12
|
+
interface Context {
|
|
13
|
+
extractStorageLayout: (
|
|
14
|
+
contract: string,
|
|
15
|
+
contractName?: string,
|
|
16
|
+
withLayout?: boolean,
|
|
17
|
+
) => Promise<ReturnType<typeof extractStorageLayout>>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const test = _test as TestFn<Context>;
|
|
21
|
+
|
|
22
|
+
test.before(async t => {
|
|
23
|
+
const buildInfoCache: Record<string, BuildInfo | undefined> = {};
|
|
24
|
+
t.context.extractStorageLayout = async (contractFile, contractName, withLayout = true) => {
|
|
25
|
+
const expectedContract = contractName ?? contractFile;
|
|
26
|
+
|
|
27
|
+
const [file] = contractFile.split('_');
|
|
28
|
+
const source = `contracts/test/${file}.sol`;
|
|
29
|
+
const buildInfo = (buildInfoCache[source] ??= await artifacts.getBuildInfo(`${source}:${expectedContract}`));
|
|
30
|
+
if (buildInfo === undefined) {
|
|
31
|
+
throw new Error(`Build info for ${source} not found`);
|
|
32
|
+
}
|
|
33
|
+
const solcOutput: SolcOutput = buildInfo.output;
|
|
34
|
+
for (const def of findAll('ContractDefinition', solcOutput.sources[source].ast)) {
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
36
|
+
const layout = solcOutput.contracts[source][def.name].storageLayout!;
|
|
37
|
+
if (def.name === expectedContract) {
|
|
38
|
+
return extractStorageLayout(def, dummyDecodeSrc, astDereferencer(solcOutput), withLayout ? layout : undefined);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
throw new Error(`Contract ${expectedContract} not found in ${source}`);
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const dummyDecodeSrc = () => 'file.sol:1';
|
|
46
|
+
|
|
47
|
+
test('memory 0.5.16', async t => {
|
|
48
|
+
const layout = await t.context.extractStorageLayout('Memory05');
|
|
49
|
+
t.snapshot(stabilizeStorageLayout(layout));
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('memory 0.8.9', async t => {
|
|
53
|
+
const layout = await t.context.extractStorageLayout('Memory08');
|
|
54
|
+
t.snapshot(stabilizeStorageLayout(layout));
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('memory - upgrade from 0.5.16 to 0.8.9', async t => {
|
|
58
|
+
const v1 = await t.context.extractStorageLayout('Memory05');
|
|
59
|
+
const v2 = await t.context.extractStorageLayout('Memory08');
|
|
60
|
+
|
|
61
|
+
const comparison = getStorageUpgradeErrors(v1, v2);
|
|
62
|
+
t.deepEqual(comparison, []);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('memory - bad upgrade from 0.5.16 to 0.8.9', async t => {
|
|
66
|
+
const v1 = await t.context.extractStorageLayout('Memory05');
|
|
67
|
+
const v2 = await t.context.extractStorageLayout('Memory08', 'Memory08Bad');
|
|
68
|
+
|
|
69
|
+
const comparison = getStorageUpgradeErrors(v1, v2);
|
|
70
|
+
t.like(comparison, {
|
|
71
|
+
length: 2,
|
|
72
|
+
0: {
|
|
73
|
+
kind: 'typechange',
|
|
74
|
+
change: {
|
|
75
|
+
kind: 'mapping key',
|
|
76
|
+
},
|
|
77
|
+
original: { label: 'a' },
|
|
78
|
+
updated: { label: 'a' },
|
|
79
|
+
},
|
|
80
|
+
1: {
|
|
81
|
+
kind: 'typechange',
|
|
82
|
+
change: {
|
|
83
|
+
kind: 'mapping key',
|
|
84
|
+
},
|
|
85
|
+
original: { label: 'b' },
|
|
86
|
+
updated: { label: 'b' },
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# Snapshot report for `src/storage-memory-0.5.test.ts`
|
|
2
|
+
|
|
3
|
+
The actual snapshot is saved in `storage-memory-0.5.test.ts.snap`.
|
|
4
|
+
|
|
5
|
+
Generated by [AVA](https://avajs.dev).
|
|
6
|
+
|
|
7
|
+
## memory 0.5.16
|
|
8
|
+
|
|
9
|
+
> Snapshot 1
|
|
10
|
+
|
|
11
|
+
{
|
|
12
|
+
storage: [
|
|
13
|
+
{
|
|
14
|
+
contract: 'Memory05',
|
|
15
|
+
label: 'a',
|
|
16
|
+
offset: 0,
|
|
17
|
+
renamedFrom: undefined,
|
|
18
|
+
retypedFrom: undefined,
|
|
19
|
+
slot: '0',
|
|
20
|
+
src: 'file.sol:1',
|
|
21
|
+
type: 't_mapping(t_string_memory,t_address)',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
contract: 'Memory05',
|
|
25
|
+
label: 'b',
|
|
26
|
+
offset: 0,
|
|
27
|
+
renamedFrom: undefined,
|
|
28
|
+
retypedFrom: undefined,
|
|
29
|
+
slot: '1',
|
|
30
|
+
src: 'file.sol:1',
|
|
31
|
+
type: 't_mapping(t_bytes_memory,t_address)',
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
types: [
|
|
35
|
+
[
|
|
36
|
+
't_address',
|
|
37
|
+
{
|
|
38
|
+
label: 'address',
|
|
39
|
+
members: undefined,
|
|
40
|
+
numberOfBytes: '20',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
[
|
|
44
|
+
't_bytes_memory',
|
|
45
|
+
{
|
|
46
|
+
label: 'bytes',
|
|
47
|
+
members: undefined,
|
|
48
|
+
numberOfBytes: '32',
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
[
|
|
52
|
+
't_mapping(t_bytes_memory,t_address)',
|
|
53
|
+
{
|
|
54
|
+
label: 'mapping(bytes => address)',
|
|
55
|
+
members: undefined,
|
|
56
|
+
numberOfBytes: '32',
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
[
|
|
60
|
+
't_mapping(t_string_memory,t_address)',
|
|
61
|
+
{
|
|
62
|
+
label: 'mapping(string => address)',
|
|
63
|
+
members: undefined,
|
|
64
|
+
numberOfBytes: '32',
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
[
|
|
68
|
+
't_string_memory',
|
|
69
|
+
{
|
|
70
|
+
label: 'string',
|
|
71
|
+
members: undefined,
|
|
72
|
+
numberOfBytes: '32',
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
[
|
|
76
|
+
't_string_storage',
|
|
77
|
+
{
|
|
78
|
+
label: 'string',
|
|
79
|
+
members: undefined,
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
[
|
|
83
|
+
't_bytes_storage',
|
|
84
|
+
{
|
|
85
|
+
label: 'bytes',
|
|
86
|
+
members: undefined,
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
],
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
## memory 0.8.9
|
|
93
|
+
|
|
94
|
+
> Snapshot 1
|
|
95
|
+
|
|
96
|
+
{
|
|
97
|
+
storage: [
|
|
98
|
+
{
|
|
99
|
+
contract: 'Memory08',
|
|
100
|
+
label: 'a',
|
|
101
|
+
offset: 0,
|
|
102
|
+
renamedFrom: undefined,
|
|
103
|
+
retypedFrom: undefined,
|
|
104
|
+
slot: '0',
|
|
105
|
+
src: 'file.sol:1',
|
|
106
|
+
type: 't_mapping(t_string_memory_ptr,t_address)',
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
contract: 'Memory08',
|
|
110
|
+
label: 'b',
|
|
111
|
+
offset: 0,
|
|
112
|
+
renamedFrom: undefined,
|
|
113
|
+
retypedFrom: undefined,
|
|
114
|
+
slot: '1',
|
|
115
|
+
src: 'file.sol:1',
|
|
116
|
+
type: 't_mapping(t_bytes_memory_ptr,t_address)',
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
types: [
|
|
120
|
+
[
|
|
121
|
+
't_address',
|
|
122
|
+
{
|
|
123
|
+
label: 'address',
|
|
124
|
+
members: undefined,
|
|
125
|
+
numberOfBytes: '20',
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
[
|
|
129
|
+
't_bytes_memory_ptr',
|
|
130
|
+
{
|
|
131
|
+
label: 'bytes',
|
|
132
|
+
members: undefined,
|
|
133
|
+
numberOfBytes: '32',
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
[
|
|
137
|
+
't_mapping(t_bytes_memory_ptr,t_address)',
|
|
138
|
+
{
|
|
139
|
+
label: 'mapping(bytes => address)',
|
|
140
|
+
members: undefined,
|
|
141
|
+
numberOfBytes: '32',
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
[
|
|
145
|
+
't_mapping(t_string_memory_ptr,t_address)',
|
|
146
|
+
{
|
|
147
|
+
label: 'mapping(string => address)',
|
|
148
|
+
members: undefined,
|
|
149
|
+
numberOfBytes: '32',
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
[
|
|
153
|
+
't_string_memory_ptr',
|
|
154
|
+
{
|
|
155
|
+
label: 'string',
|
|
156
|
+
members: undefined,
|
|
157
|
+
numberOfBytes: '32',
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
[
|
|
161
|
+
't_string_storage',
|
|
162
|
+
{
|
|
163
|
+
label: 'string',
|
|
164
|
+
members: undefined,
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
[
|
|
168
|
+
't_bytes_storage',
|
|
169
|
+
{
|
|
170
|
+
label: 'bytes',
|
|
171
|
+
members: undefined,
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
],
|
|
175
|
+
}
|
|
Binary file
|