From 98327d1f4732a417a878e93e8d94362da35152de Mon Sep 17 00:00:00 2001 From: r0qs Date: Thu, 23 Jan 2025 16:36:51 +0100 Subject: [PATCH 01/10] Drop nodejs 10 --- .circleci/config.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f6450c2b..25fe7dae 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,6 @@ workflows: pr-checks: jobs: - check-coding-style - - node-v10 - node-v12 - node-v14 - node-v16 @@ -345,10 +344,6 @@ jobs: - run: cd solidity/ && curl "https://binaries.soliditylang.org/bin/soljson-nightly.js" --location --output soljson.js - run: cd solidity/ && test/externalTests/solc-js/solc-js.sh "$(realpath soljson.js)" "$(scripts/get_version.sh)" "$(realpath ../solc-js/)" - node-v10: - <<: *node-base - docker: - - image: cimg/node:10.24 node-v12: <<: *node-base docker: From b8be3e4b38cab8556e5dc90f7936b5c5b06fde5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Fri, 24 Jan 2025 23:27:44 +0100 Subject: [PATCH 02/10] package-json-with-min-dependencies.sh: Script for updating package.json to use oldest supported dependencies --- .../package-json-with-min-dependencies.sh | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 .circleci/package-json-with-min-dependencies.sh diff --git a/.circleci/package-json-with-min-dependencies.sh b/.circleci/package-json-with-min-dependencies.sh new file mode 100755 index 00000000..7fd959dd --- /dev/null +++ b/.circleci/package-json-with-min-dependencies.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash +# Creates a variant of package.json, hard-coded to use the oldest version of each dependency in +# the supported range. +# +# package.json is taken from the current working directory. The script does not modify the file - +# the new version is instead printed to the standard output. +# +# Dependencies: npm, jq, semver + +set -euo pipefail + +function fail { >&2 echo "$@"; exit 1; } + +function find_min_supported_versions { + local packages_json min_versions packages supported_range available_versions min_version + + # The function expects a JSON dict with package names and versions, extracted from package.json by the caller. + packages_json=$(cat -) + + # Use @tsv filter to get tab-separated package names. We assume that neither packages, nor + # available versions contain spaces. Spaces in version range are fine though. + packages=$(echo "$packages_json" | jq --raw-output 'keys | @tsv') + min_versions=() + for package in $packages; do + available_versions=$(npm view "$package" versions --json | jq --raw-output @tsv) + supported_range=$(echo "$packages_json" | jq --raw-output ".\"${package}\"") + + # shellcheck disable=SC2086 + # semver prints versions matching the range, one per line, in semver order, oldest first + min_version=$(semver $available_versions --range "$supported_range" | head --lines 1) + [[ $min_version != "" ]] || fail "No version matching ${supported_range} found for package ${package}." + + # Debug info. It goes to stderr not to interfere with actual output. + >&2 echo "Package ${package}:" + >&2 echo " minimum version: ${min_version}" + >&2 echo " supported range: ${supported_range}" + >&2 echo " available versions: ${available_versions}" + >&2 echo + + min_versions+=("{\"${package}\": \"${min_version}\"}") + done + + # Actual output: min_versions merged into a single dict. + echo "${min_versions[@]}" | jq --slurp add +} + +dependencies=$(jq .dependencies package.json | find_min_supported_versions) +dev_dependencies=$(jq .devDependencies package.json | find_min_supported_versions) + +# Print package.json with overwritten dependency versions +cat < Date: Fri, 24 Jan 2025 23:28:24 +0100 Subject: [PATCH 03/10] CI: Run tests with minimum dependencies on the newest and oldest node.js --- .circleci/config.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 25fe7dae..7bd7aaa3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,12 +9,18 @@ workflows: jobs: - check-coding-style - node-v12 + - node-v12: + name: node-v12-min-dependencies + min_dependencies: true - node-v14 - node-v16 - node-v18 - node-v20 - node-current: run_coveralls: true + - node-current: + name: node-current-min-dependencies + min_dependencies: true - build-package - hardhat-sample-project: *requires_package - cli-smoke-test: *requires_package @@ -167,10 +173,31 @@ jobs: run_coveralls: type: boolean default: false + min_dependencies: + description: "Install the oldest dependencies still matching ranges specified in package.json" + type: boolean + default: false steps: # We want the default npm here. Older one might not work with older node.js - show-npm-version - checkout + - when: + condition: <> + steps: + - run: + name: Install the semver utility + command: | + # NOTE: Newer cimg/node images require sudo here, older don't. Try both. + sudo npm install semver --global || npm install semver --global + - run: + name: Force oldest supported dependency versions in package.json + command: | + min_package_json=$(.circleci/package-json-with-min-dependencies.sh) + echo "$min_package_json" > package.json + - run: + name: "Show selected dependency versions" + command: | + jq 'with_entries(select(.key == "dependencies" or .key == "devDependencies"))' package.json --indent 4 - install-dependencies: cache-id: solc-js - run: From ebdcf4dd125e41daa90344ff3600611279988c47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Sat, 25 Jan 2025 01:41:46 +0100 Subject: [PATCH 04/10] Fix the object-shorthand warnings that popped up after eslint update --- formatters.ts | 2 +- smtsolver.ts | 2 +- solc.ts | 2 +- test/smtcallback.ts | 8 ++++---- test/smtchecker.ts | 2 +- translate.ts | 2 +- wrapper.ts | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/formatters.ts b/formatters.ts index 4ad82028..c9d90251 100644 --- a/formatters.ts +++ b/formatters.ts @@ -5,7 +5,7 @@ export function formatFatalError (message) { type: 'JSONError', component: 'solcjs', severity: 'error', - message: message, + message, formattedMessage: 'Error: ' + message } ] diff --git a/smtsolver.ts b/smtsolver.ts index 29993a18..2e444d26 100644 --- a/smtsolver.ts +++ b/smtsolver.ts @@ -44,7 +44,7 @@ function solve (query, solver) { encoding: 'utf8', maxBuffer: 1024 * 1024 * 1024, stdio: 'pipe', - timeout: timeout // Enforce timeout on the process, since solvers can sometimes go around it. + timeout // Enforce timeout on the process, since solvers can sometimes go around it. } ).toString(); } catch (e) { diff --git a/solc.ts b/solc.ts index 10dc8ed3..fbe4c8e3 100755 --- a/solc.ts +++ b/solc.ts @@ -201,7 +201,7 @@ const cliInput = { } } }, - sources: sources + sources }; if (program.verbose) { console.log('>>> Compiling:\n' + toFormattedJson(cliInput) + '\n'); } const output = JSON.parse(solc.compile(JSON.stringify(cliInput), callbacks)); diff --git a/test/smtcallback.ts b/test/smtcallback.ts index 726cc87e..7133cfec 100644 --- a/test/smtcallback.ts +++ b/test/smtcallback.ts @@ -85,7 +85,7 @@ tape('SMTCheckerCallback', function (t) { const inputJSON = JSON.stringify({ language: 'Solidity', sources: input, - settings: settings + settings }); let tests; @@ -192,7 +192,7 @@ tape('SMTCheckerCallback', function (t) { expectations: expected, solidity: { test: { content: preamble + source } }, ignoreCex: source.includes('// SMTIgnoreCex: yes'), - engine: engine + engine }; } @@ -214,7 +214,7 @@ tape('SMTCheckerCallback', function (t) { const engine = test.engine !== undefined ? test.engine : 'all'; settings = { modelChecker: { - engine: engine, + engine, solvers: [ 'smtlib2' ] @@ -225,7 +225,7 @@ tape('SMTCheckerCallback', function (t) { JSON.stringify({ language: 'Solidity', sources: test.solidity, - settings: settings + settings }), // This test needs z3 specifically. { smtSolver: smtchecker.smtCallback(smtsolver.smtSolver, z3HornSolvers[0]) } diff --git a/test/smtchecker.ts b/test/smtchecker.ts index 70193339..ea71db72 100644 --- a/test/smtchecker.ts +++ b/test/smtchecker.ts @@ -84,7 +84,7 @@ tape('SMTCheckerWithSolver', function (t) { const input = { language: 'Solidity', sources: source, - settings: settings + settings }; const output = JSON.parse(solc.compile(JSON.stringify(input))); diff --git a/translate.ts b/translate.ts index ca0c39f7..fe0d2f4c 100644 --- a/translate.ts +++ b/translate.ts @@ -38,7 +38,7 @@ function translateErrors (ret, errors) { type = 'Error'; } ret.push({ - type: type, + type, component: 'general', severity: (type === 'Warning') ? 'warning' : 'error', message: errors[error], diff --git a/wrapper.ts b/wrapper.ts index e9bf471e..ce6a9ccc 100755 --- a/wrapper.ts +++ b/wrapper.ts @@ -101,13 +101,13 @@ function compileStandardWrapper (compile, inputRaw, readCallback) { // Try to wrap around old versions if (!isNil(compile.compileJsonCallback)) { - const inputJson = JSON.stringify({ sources: sources }); + const inputJson = JSON.stringify({ sources }); const output = compile.compileJsonCallback(inputJson, optimize, readCallback); return translateOutput(output, libraries); } if (!isNil(compile.compileJsonMulti)) { - const output = compile.compileJsonMulti(JSON.stringify({ sources: sources }), optimize); + const output = compile.compileJsonMulti(JSON.stringify({ sources }), optimize); return translateOutput(output, libraries); } From 1833cf0619cd4c7df0d8b5f6cb6d8873cca71b54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Sat, 25 Jan 2025 01:48:20 +0100 Subject: [PATCH 05/10] solcjs: Remove the redundant --version option, conflicting with the built-in one - This started causing an error with the latest version of the commander package --- solc.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/solc.ts b/solc.ts index fbe4c8e3..9d4f8bfb 100755 --- a/solc.ts +++ b/solc.ts @@ -26,7 +26,6 @@ const commanderParseInt = function (value) { program.name('solcjs'); program.version(solc.version()); program - .option('--version', 'Show version and exit.') .option('--optimize', 'Enable bytecode optimizer.', false) .option( '--optimize-runs ', From 9bfa6160671b0a417ce6d92641e6da267d129f08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Sat, 25 Jan 2025 01:11:03 +0100 Subject: [PATCH 06/10] package.json: Accept older dependency versions in cases where the package can still work with them --- package.json | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 3510d2e1..1377e941 100644 --- a/package.json +++ b/package.json @@ -46,32 +46,32 @@ }, "homepage": "https://github.com/ethereum/solc-js#readme", "dependencies": { - "command-exists": "^1.2.8", - "commander": "^8.1.0", - "follow-redirects": "^1.12.1", + "command-exists": "^1.1.0", + "commander": "^8.0.0", + "follow-redirects": "^1.0.0", "js-sha3": "0.8.0", - "memorystream": "^0.3.1", - "semver": "^5.5.0", + "memorystream": "^0.3.0", + "semver": "^5.0.0", "tmp": "0.0.33" }, "devDependencies": { "@types/node": "^16.11.7", - "@types/semver": "^7.3.9", - "@types/tape": "^4.13.2", - "@types/tmp": "^0.2.3", - "@typescript-eslint/eslint-plugin": "^5.8.0", - "@typescript-eslint/parser": "^5.8.0", + "@types/semver": "^7.1.0", + "@types/tape": "^4.2.27", + "@types/tmp": "^0.2.0", + "@typescript-eslint/eslint-plugin": "^5.0.0", + "@typescript-eslint/parser": "^5.0.0", "coveralls": "^3.0.0", - "eslint": "^7.32.0", + "eslint": "^7.12.1", "eslint-config-standard": "^16.0.3", - "eslint-plugin-import": "^2.25.3", + "eslint-plugin-import": "^2.25.0", "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^5.1.1", - "nyc": "^15.1.0", + "eslint-plugin-promise": "^5.0.0", + "nyc": "^15.0.0", "tape": "^4.11.0", - "tape-spawn": "^1.4.2", - "ts-node": "^10.4.0", - "typescript": "^4.5.4" + "tape-spawn": "^1.0.0", + "ts-node": "^10.0.0", + "typescript": "^4.2.2" }, "nyc": { "exclude": [ From 591df889e5d81723748b8f44fa0887401a43c02f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Sat, 25 Jan 2025 01:11:28 +0100 Subject: [PATCH 07/10] package.json: Accept a wider range of versions for the `tmp` and `js-sha3` dependencies --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1377e941..bd815b3e 100644 --- a/package.json +++ b/package.json @@ -49,10 +49,10 @@ "command-exists": "^1.1.0", "commander": "^8.0.0", "follow-redirects": "^1.0.0", - "js-sha3": "0.8.0", + "js-sha3": "^0.8.0", "memorystream": "^0.3.0", "semver": "^5.0.0", - "tmp": "0.0.33" + "tmp": "^0.0.26" }, "devDependencies": { "@types/node": "^16.11.7", From 156e4b0bf916313abbb81a5f74b7e58c3d0cc900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Sat, 25 Jan 2025 01:30:01 +0100 Subject: [PATCH 08/10] package.json: Adjust dependencies to accept updates even across breaking versions by default --- package.json | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index bd815b3e..030508d2 100644 --- a/package.json +++ b/package.json @@ -46,32 +46,32 @@ }, "homepage": "https://github.com/ethereum/solc-js#readme", "dependencies": { - "command-exists": "^1.1.0", - "commander": "^8.0.0", - "follow-redirects": "^1.0.0", - "js-sha3": "^0.8.0", - "memorystream": "^0.3.0", - "semver": "^5.0.0", - "tmp": "^0.0.26" + "command-exists": ">=1.1.0", + "commander": ">=8.0.0", + "follow-redirects": ">=1.0.0", + "js-sha3": ">=0.8.0", + "memorystream": ">=0.3.0", + "semver": ">=5.0.0", + "tmp": ">=0.0.26" }, "devDependencies": { - "@types/node": "^16.11.7", - "@types/semver": "^7.1.0", - "@types/tape": "^4.2.27", - "@types/tmp": "^0.2.0", - "@typescript-eslint/eslint-plugin": "^5.0.0", - "@typescript-eslint/parser": "^5.0.0", - "coveralls": "^3.0.0", - "eslint": "^7.12.1", - "eslint-config-standard": "^16.0.3", - "eslint-plugin-import": "^2.25.0", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^5.0.0", - "nyc": "^15.0.0", - "tape": "^4.11.0", - "tape-spawn": "^1.0.0", - "ts-node": "^10.0.0", - "typescript": "^4.2.2" + "@types/node": ">=16.11.7", + "@types/semver": ">=7.1.0", + "@types/tape": ">=4.2.27", + "@types/tmp": ">=0.2.0", + "@typescript-eslint/eslint-plugin": ">=5.0.0", + "@typescript-eslint/parser": ">=5.0.0", + "coveralls": ">=3.0.0", + "eslint": ">=7.12.1", + "eslint-config-standard": ">=16.0.3", + "eslint-plugin-import": ">=2.25.0", + "eslint-plugin-node": ">=11.1.0", + "eslint-plugin-promise": ">=5.0.0", + "nyc": ">=15.0.0", + "tape": ">=4.11.0", + "tape-spawn": ">=1.0.0", + "ts-node": ">=10.0.0", + "typescript": ">=4.2.2" }, "nyc": { "exclude": [ From 15f272b5f366d4f76cdc6d7fe2871102997c17a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Sat, 25 Jan 2025 01:54:43 +0100 Subject: [PATCH 09/10] package.json: Restrict commander to <13.0.0 until we're ready to upgrade - The latest version fails our test suite. Upgrading will require adjusting the code. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 030508d2..a0d6fbd3 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "homepage": "https://github.com/ethereum/solc-js#readme", "dependencies": { "command-exists": ">=1.1.0", - "commander": ">=8.0.0", + "commander": ">=8.0.0 <13.0.0", "follow-redirects": ">=1.0.0", "js-sha3": ">=0.8.0", "memorystream": ">=0.3.0", From 284967f147f04f20c63cbe5998da4b944b276652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Sat, 25 Jan 2025 02:07:09 +0100 Subject: [PATCH 10/10] package.json: Restrict versions of dependencies that fail on node v12 and v14 due to problems with ?? operator --- package.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index a0d6fbd3..f200f15b 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "homepage": "https://github.com/ethereum/solc-js#readme", "dependencies": { "command-exists": ">=1.1.0", - "commander": ">=8.0.0 <13.0.0", + "commander": ">=8.0.0 <12.0.0", "follow-redirects": ">=1.0.0", "js-sha3": ">=0.8.0", "memorystream": ">=0.3.0", @@ -59,19 +59,19 @@ "@types/semver": ">=7.1.0", "@types/tape": ">=4.2.27", "@types/tmp": ">=0.2.0", - "@typescript-eslint/eslint-plugin": ">=5.0.0", - "@typescript-eslint/parser": ">=5.0.0", + "@typescript-eslint/eslint-plugin": ">=5.0.0 <6.0.0", + "@typescript-eslint/parser": ">=5.0.0 <6.0.0", "coveralls": ">=3.0.0", - "eslint": ">=7.12.1", - "eslint-config-standard": ">=16.0.3", + "eslint": ">=7.12.1 <8.0.0", + "eslint-config-standard": ">=16.0.3 <17.0.0", "eslint-plugin-import": ">=2.25.0", "eslint-plugin-node": ">=11.1.0", - "eslint-plugin-promise": ">=5.0.0", + "eslint-plugin-promise": ">=5.0.0 <7.0.0", "nyc": ">=15.0.0", "tape": ">=4.11.0", "tape-spawn": ">=1.0.0", "ts-node": ">=10.0.0", - "typescript": ">=4.2.2" + "typescript": ">=4.2.2 <5.0.0" }, "nyc": { "exclude": [