Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Bump pragma to 0.8.22 for all contract that depend on ERC1967Utils #5273

Merged
merged 8 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/seven-donkeys-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': patch
---

Update some pragma directives to ensure that all file requirements match that of the files they import.
4 changes: 4 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ jobs:
run: npm run test
- name: Check linearisation of the inheritance graph
run: npm run test:inheritance
- name: Check pragma consistency between files
run: npm run test:pragma
- name: Check proceduraly generated contracts are up-to-date
run: npm run test:generation
- name: Compare gas costs
Expand Down Expand Up @@ -68,6 +70,8 @@ jobs:
run: npm run test
- name: Check linearisation of the inheritance graph
run: npm run test:inheritance
- name: Check pragma consistency between files
run: npm run test:pragma
- name: Check storage layout
uses: ./.github/actions/storage-layout
continue-on-error: ${{ contains(github.event.pull_request.labels.*.name, 'breaking change') }}
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/DummyImplementation.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;
pragma solidity ^0.8.22;

import {ERC1967Utils} from "../proxy/ERC1967/ERC1967Utils.sol";
import {StorageSlot} from "../utils/StorageSlot.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/MerkleTreeMock.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;
pragma solidity ^0.8.20;

import {MerkleTree} from "../utils/structs/MerkleTree.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/Stateless.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;
pragma solidity ^0.8.22;

// We keep these imports and a dummy contract just to we can run the test suite after transpilation.

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/governance/GovernorStorageMock.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.19;
pragma solidity ^0.8.20;

import {IGovernor, Governor} from "../../governance/Governor.sol";
import {GovernorTimelockControl} from "../../governance/extensions/GovernorTimelockControl.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/proxy/UUPSUpgradeableMock.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;
pragma solidity ^0.8.22;

import {UUPSUpgradeable} from "../../proxy/utils/UUPSUpgradeable.sol";
import {ERC1967Utils} from "../../proxy/ERC1967/ERC1967Utils.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/proxy/ERC1967/ERC1967Proxy.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (proxy/ERC1967/ERC1967Proxy.sol)

pragma solidity ^0.8.20;
pragma solidity ^0.8.22;

import {Proxy} from "../Proxy.sol";
import {ERC1967Utils} from "./ERC1967Utils.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/proxy/ERC1967/ERC1967Utils.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (proxy/ERC1967/ERC1967Utils.sol)

pragma solidity ^0.8.21;
pragma solidity ^0.8.22;

import {IBeacon} from "../beacon/IBeacon.sol";
import {IERC1967} from "../../interfaces/IERC1967.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/proxy/beacon/BeaconProxy.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (proxy/beacon/BeaconProxy.sol)

pragma solidity ^0.8.20;
pragma solidity ^0.8.22;

import {IBeacon} from "./IBeacon.sol";
import {Proxy} from "../Proxy.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/proxy/transparent/ProxyAdmin.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (proxy/transparent/ProxyAdmin.sol)

pragma solidity ^0.8.20;
pragma solidity ^0.8.22;

import {ITransparentUpgradeableProxy} from "./TransparentUpgradeableProxy.sol";
import {Ownable} from "../../access/Ownable.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (proxy/transparent/TransparentUpgradeableProxy.sol)

pragma solidity ^0.8.20;
pragma solidity ^0.8.22;

import {ERC1967Utils} from "../ERC1967/ERC1967Utils.sol";
import {ERC1967Proxy} from "../ERC1967/ERC1967Proxy.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/proxy/utils/UUPSUpgradeable.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.20;
pragma solidity ^0.8.22;

import {IERC1822Proxiable} from "../../interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "../ERC1967/ERC1967Utils.sol";
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
"generate": "scripts/generate/run.js",
"version": "scripts/release/version.sh",
"test": "hardhat test",
"test:inheritance": "scripts/checks/inheritance-ordering.js artifacts/build-info/*",
"test:generation": "scripts/checks/generation.sh",
"test:inheritance": "scripts/checks/inheritance-ordering.js artifacts/build-info/*",
"test:pragma": "scripts/checks/pragma-consistency.js artifacts/build-info/*",
"gas-report": "env ENABLE_GAS_REPORT=true npm run test",
"slither": "npm run clean && slither ."
},
Expand Down
9 changes: 5 additions & 4 deletions scripts/checks/inheritance-ordering.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

const path = require('path');
const graphlib = require('graphlib');
const match = require('micromatch');
const { findAll } = require('solidity-ast/utils');
const { _: artifacts } = require('yargs').argv;

// files to skip
const skipPatterns = ['contracts-exposed/**', 'contracts/mocks/**'];

for (const artifact of artifacts) {
const { output: solcOutput } = require(path.resolve(__dirname, '../..', artifact));

Expand All @@ -13,10 +17,7 @@ for (const artifact of artifacts) {
const linearized = [];

for (const source in solcOutput.contracts) {
if (['contracts-exposed/', 'contracts/mocks/'].some(pattern => source.startsWith(pattern))) {
continue;
}

if (match.any(source, skipPatterns)) continue;
for (const contractDef of findAll('ContractDefinition', solcOutput.sources[source].ast)) {
names[contractDef.id] = contractDef.name;
linearized.push(contractDef.linearizedBaseContracts);
Expand Down
49 changes: 49 additions & 0 deletions scripts/checks/pragma-consistency.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env node

const path = require('path');
const semver = require('semver');
const match = require('micromatch');
const { findAll } = require('solidity-ast/utils');
const { _: artifacts } = require('yargs').argv;

// files to skip
const skipPatterns = ['contracts-exposed/**', 'contracts/mocks/WithInit.sol'];

for (const artifact of artifacts) {
const { output: solcOutput } = require(path.resolve(__dirname, '../..', artifact));

const pragma = {};

// Extract pragma directive for all files
for (const source in solcOutput.contracts) {
if (match.any(source, skipPatterns)) continue;
for (const { literals } of findAll('PragmaDirective', solcOutput.sources[source].ast)) {
// There should only be one.
const [first, ...rest] = literals;
if (first === 'solidity') pragma[source] = rest.join('');
}
}

// Compare the pragma directive of the file, to that of the files it imports
for (const source in solcOutput.contracts) {
if (match.any(source, skipPatterns)) continue;
// minimum version of the compiler that matches source's pragma
const minVersion = semver.minVersion(pragma[source]);
// loop over all imports in source
for (const { absolutePath } of findAll('ImportDirective', solcOutput.sources[source].ast)) {
// So files that only import without declaring anything cause issues, because they don't shop in in "pragma"
if (!pragma[absolutePath]) continue;
// Check that the minVersion for source satisfies the requirements of the imported files
if (!semver.satisfies(minVersion, pragma[absolutePath])) {
console.log(
`- ${source} uses ${pragma[source]} but depends on ${absolutePath} that requires ${pragma[absolutePath]}`,
);
process.exitCode = 1;
}
}
}
}

if (!process.exitCode) {
console.log('Pragma directives are consistent.');
}