diff --git a/.github/workflows/call.deploy-dry-run.yml b/.github/workflows/call.deploy-dry-run.yml index f09cf98d1f..b0c4f33f41 100644 --- a/.github/workflows/call.deploy-dry-run.yml +++ b/.github/workflows/call.deploy-dry-run.yml @@ -6,9 +6,6 @@ on: network: required: true type: string - network-id: - required: true - type: string provider-url: required: true type: string @@ -28,8 +25,11 @@ jobs: yarn install --frozen-lockfile yarn build-for-contracts-dev - - name: Start ganache - run: npx ganache --port 47545 --mnemonic --fork.url ${{ github.event.inputs.provider-url }} --network-id ${{ github.event.inputs.network-id }} --chain.chainId ${{ github.event.inputs.network-id }} + - name: Start hardhat node + run: | + cd ${{ env.ethereum-contracts-working-directory }} + npx hardhat node --port 47545 --fork ${{ github.event.inputs.provider-url }} & + sleep 5 - name: Deploy framework run: | diff --git a/packages/automation-contracts/autowrap/foundry.toml b/packages/automation-contracts/autowrap/foundry.toml index a724979827..61775d11b7 100644 --- a/packages/automation-contracts/autowrap/foundry.toml +++ b/packages/automation-contracts/autowrap/foundry.toml @@ -3,7 +3,7 @@ root = '../../../' libs = ['lib'] src = 'packages/automation-contracts/autowrap' solc_version = "0.8.30" -evm_version = 'shanghai' +evm_version = 'cancun' optimizer = true optimizer_runs = 200 remappings = [ diff --git a/packages/automation-contracts/scheduler/foundry.toml b/packages/automation-contracts/scheduler/foundry.toml index d430bfbe9f..aa61497fdf 100644 --- a/packages/automation-contracts/scheduler/foundry.toml +++ b/packages/automation-contracts/scheduler/foundry.toml @@ -3,7 +3,7 @@ root = '../../../' libs = ['lib'] src = 'packages/automation-contracts/scheduler' solc_version = "0.8.30" -evm_version = 'shanghai' +evm_version = 'cancun' optimizer = true optimizer_runs = 200 remappings = [ diff --git a/packages/ethereum-contracts/CHANGELOG.md b/packages/ethereum-contracts/CHANGELOG.md index e38a847b62..0d73f219ca 100644 --- a/packages/ethereum-contracts/CHANGELOG.md +++ b/packages/ethereum-contracts/CHANGELOG.md @@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Changed +- EVM target changed from _shanghai_ to _cancun_. - Update solhint to v6. ## [v1.14.1] diff --git a/packages/ethereum-contracts/README.md b/packages/ethereum-contracts/README.md index 9330f7d6b1..5d1d27d658 100644 --- a/packages/ethereum-contracts/README.md +++ b/packages/ethereum-contracts/README.md @@ -355,7 +355,7 @@ Run the test suite for core contracts: yarn run-hardhat test testsuites/superfluid-core.js ``` -The `pretest` script starts a ganache instance with deterministic accounts in the background, the `posttest` script stops it. +The `pretest` script starts a local dev chain with deterministic accounts in the background, the `posttest` script stops it. When running tests with `yarn test`, those get executed automatically (see [npm docs](https://docs.npmjs.com/cli/v7/using-npm/scripts#pre--post-scripts)). > NOTE: You don't need to run the `pretest` and `posttest` scripts when running hardhat tests, but you do when running tests with truffle. diff --git a/packages/ethereum-contracts/foundry.toml b/packages/ethereum-contracts/foundry.toml index d0e6a3f967..350cd10e1c 100644 --- a/packages/ethereum-contracts/foundry.toml +++ b/packages/ethereum-contracts/foundry.toml @@ -8,7 +8,7 @@ ignored_error_codes = [ 1699 # assembly { selfdestruct } in contracts/mocks/SuperfluidDestructorMock.sol ] # keep in sync with truffle-config.js -evm_version = 'shanghai' +evm_version = 'cancun' optimizer = true optimizer_runs = 200 remappings = [ diff --git a/packages/ethereum-contracts/hardhat.config.ts b/packages/ethereum-contracts/hardhat.config.ts index e8ecc1933f..46d41394b0 100644 --- a/packages/ethereum-contracts/hardhat.config.ts +++ b/packages/ethereum-contracts/hardhat.config.ts @@ -105,7 +105,7 @@ const config: HardhatUserConfig = { enabled: true, runs: 200, }, - evmVersion: "shanghai", + evmVersion: "cancun", }, }, paths: { @@ -159,6 +159,10 @@ const config: HardhatUserConfig = { hardhat: { // We defer the contract size limit test to foundry. allowUnlimitedContractSize: true, + // Expected by testenv-ctl.sh + accounts: { + mnemonic: "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat", + }, }, }, mocha: { diff --git a/packages/ethereum-contracts/ops-scripts/libs/getConfig.js b/packages/ethereum-contracts/ops-scripts/libs/getConfig.js index d1985387a2..099a574865 100644 --- a/packages/ethereum-contracts/ops-scripts/libs/getConfig.js +++ b/packages/ethereum-contracts/ops-scripts/libs/getConfig.js @@ -6,13 +6,8 @@ module.exports = function getConfig(chainId) { // here go the trusted forwarders which aren't part of the framework contracts // Local Testing - 4447: { - // for local testing (truffle internal ganache and TestEnvironment) - // this is a fake forwarder address, it is to test the deployment script - trustedForwarders: ["0x3075b4dc7085C48A14A5A39BBa68F58B19545971"], - }, - 5777: { - // for local testing (external ganache) + 31337: { + // for local testing (hardhat node default chainId) // this is a fake forwarder address, it is to test the deployment script trustedForwarders: ["0x3075b4dc7085C48A14A5A39BBa68F58B19545971"], }, diff --git a/packages/ethereum-contracts/package.json b/packages/ethereum-contracts/package.json index e0c0581858..cca0215676 100644 --- a/packages/ethereum-contracts/package.json +++ b/packages/ethereum-contracts/package.json @@ -22,10 +22,9 @@ "async": "^3.2.6", "csv-writer": "^1.6.0", "ethers": "^5.7.2", - "ganache-time-traveler": "^1.0.16", "mochawesome": "^7.1.3", "readline": "^1.3.0", - "solidity-coverage": "^0.8.12", + "solidity-coverage": "^0.8.17", "solidity-docgen": "^0.6.0-beta.36", "stack-trace": "0.0.10", "truffle-flattener": "^1.6.0" diff --git a/packages/ethereum-contracts/test/TestEnvironment.ts b/packages/ethereum-contracts/test/TestEnvironment.ts index 560e63ffb8..b43a2558be 100644 --- a/packages/ethereum-contracts/test/TestEnvironment.ts +++ b/packages/ethereum-contracts/test/TestEnvironment.ts @@ -32,7 +32,6 @@ import { const {web3tx, wad4human} = require("@decentral.ee/web3-helpers"); const SuperfluidSDK = require("@superfluid-finance/js-sdk"); -const traveler = require("ganache-time-traveler"); const deployFramework = require("../ops-scripts/deploy-framework"); const deploySuperToken = require("../ops-scripts/deploy-super-token"); @@ -161,6 +160,22 @@ export default class TestEnvironment { console.debug("popEvmSnapshot", JSON.stringify(this._evmSnapshots)); } + /** + * Advance time by specified seconds and mine a block (replaces ganache-time-traveler.advanceTimeAndBlock) + */ + async _advanceTimeAndBlock(seconds: number) { + await network.provider.send("evm_increaseTime", [seconds]); + await network.provider.send("evm_mine", []); + } + + /** + * Set the next block's timestamp and mine a block (replaces ganache-time-traveler.advanceBlockAndSetTime) + * Uses evm_mine with timestamp parameter, matching ganache-time-traveler behavior + */ + async _advanceBlockAndSetTime(timestamp: number) { + await network.provider.send("evm_mine", [timestamp]); + } + async useLastEvmSnapshot() { let oldEvmSnapshotId = ""; const popped = this._evmSnapshots.pop(); @@ -171,10 +186,6 @@ export default class TestEnvironment { } = popped); } await this._revertToEvmSnapShot(oldEvmSnapshotId); - // move the time to now - await traveler.advanceBlockAndSetTime( - parseInt((Date.now() / 1000).toString()) - ); const newEvmSnapshotId = await this._takeEvmSnapshot(); this._evmSnapshots.push({ id: newEvmSnapshotId, @@ -192,7 +203,7 @@ export default class TestEnvironment { const block1 = await ethers.provider.getBlock("latest"); console.log("current block time", block1.timestamp); console.log(`time traveler going to the future +${jsNumTime}...`); - await traveler.advanceTimeAndBlock(jsNumTime); + await this._advanceTimeAndBlock(jsNumTime); const block2 = await ethers.provider.getBlock("latest"); console.log("new block time", block2.timestamp); } diff --git a/packages/ethereum-contracts/test/testenv-ctl.sh b/packages/ethereum-contracts/test/testenv-ctl.sh index cd81f6a2cf..147acf6422 100755 --- a/packages/ethereum-contracts/test/testenv-ctl.sh +++ b/packages/ethereum-contracts/test/testenv-ctl.sh @@ -3,21 +3,19 @@ # make sure that if any step fails, the script fails set -xe -TESTENV_MNEMONIC="candy maple cake sugar pudding cream honey rich smooth crumble sweet treat" - CMD=$1 -start_ganache() { - ganache-cli --networkId 4447 --port 47545 --mnemonic "$TESTENV_MNEMONIC" +start_hardhat_node() { + npx hardhat node --port 47545 } -kill_ganache() { - pkill -f "ganache-cli --networkId 4447" || true +kill_hardhat_node() { + pkill -f "hardhat node --port 47545" || true } if [ "$CMD" == "start" ];then - kill_ganache - start_ganache + kill_hardhat_node + start_hardhat_node elif [ "$CMD" == "stop" ];then - kill_ganache + kill_hardhat_node fi diff --git a/packages/ethereum-contracts/truffle-config.js b/packages/ethereum-contracts/truffle-config.js index cc53fc2335..9dd7ba3ad2 100644 --- a/packages/ethereum-contracts/truffle-config.js +++ b/packages/ethereum-contracts/truffle-config.js @@ -171,8 +171,8 @@ const E = (module.exports = { networks: { // Useful for testing. The `development` name is special - truffle uses it by default // if it's defined here and no other network is specified at the command line. - // You should run a client (like ganache-cli, geth or parity) in a separate terminal - // tab if you use this network and you must also set the `host`, `port` and `network_id` + // You should run a client in a separate terminal tab + // if you use this network and you must also set the `host`, `port` and `network_id` // options below to some value. // @@ -312,7 +312,7 @@ const E = (module.exports = { development: { host: "127.0.0.1", port: 47545, - network_id: "4447", + network_id: "31337", // hardhat default chainId // workaround to improve testing speed // see https://github.com/trufflesuite/truffle/issues/3522 @@ -389,7 +389,7 @@ const E = (module.exports = { runs: 200, }, // see https://docs.soliditylang.org/en/latest/using-the-compiler.html#target-options - evmVersion: "shanghai", + evmVersion: "cancun", }, }, }, diff --git a/packages/hot-fuzz/foundry.toml b/packages/hot-fuzz/foundry.toml index 2d630772b8..c2769d9c2b 100644 --- a/packages/hot-fuzz/foundry.toml +++ b/packages/hot-fuzz/foundry.toml @@ -2,7 +2,7 @@ root = '../..' src = 'packages/hot-fuzz/contracts' solc_version = "0.8.30" -evm_version = 'shanghai' +evm_version = 'cancun' optimizer = true optimizer_runs = 200 remappings = [ diff --git a/yarn.lock b/yarn.lock index 293ddb8ca6..4950cc8830 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3672,10 +3672,10 @@ dependencies: antlr4ts "^0.5.0-alpha.4" -"@solidity-parser/parser@^0.18.0": - version "0.18.0" - resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.18.0.tgz#8e77a02a09ecce957255a2f48c9a7178ec191908" - integrity sha512-yfORGUIPgLck41qyN7nbwJRAx17/jAIXCTanHOJZhB6PJ1iAk/84b/xlsVKFSyNyLXIj0dhppoE0+CRws7wlzA== +"@solidity-parser/parser@^0.20.1", "@solidity-parser/parser@^0.20.2": + version "0.20.2" + resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.20.2.tgz#e07053488ed60dae1b54f6fe37bb6d2c5fe146a7" + integrity sha512-rbu0bzwNvMcwAjH86hiEAcOeRI2EeK8zCkHDrFykh/Al8mvJeFmjy3UrE7GYQjNwOgbGUUtCn5/k8CB8zIu7QA== "@solidity-parser/parser@^0.20.2": version "0.20.2" @@ -9675,11 +9675,6 @@ functions-have-names@^1.2.3: resolved "https://registry.yarnpkg.com/functions-have-names/-/functions-have-names-1.2.3.tgz#0404fe4ee2ba2f607f0e0ec3c80bae994133b834" integrity sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ== -ganache-time-traveler@^1.0.16: - version "1.0.16" - resolved "https://registry.yarnpkg.com/ganache-time-traveler/-/ganache-time-traveler-1.0.16.tgz#9ddeafd72c909ecd3501e4ec628a3af707334b3a" - integrity sha512-oUaQge9tiT/zzcGqehqJcoH10claKi9QFhq7zI1Wa3KtdPobjgLVMYvqXCJuHCAZoS7sHvLB/N/rSnhmivxaKw== - ganache@7.9.1: version "7.9.1" resolved "https://registry.yarnpkg.com/ganache/-/ganache-7.9.1.tgz#94f8518215c7989ff5fd542db80bd47d7c7da786" @@ -16581,13 +16576,13 @@ solidity-comments-extractor@^0.0.7: resolved "https://registry.yarnpkg.com/solidity-comments-extractor/-/solidity-comments-extractor-0.0.7.tgz#99d8f1361438f84019795d928b931f4e5c39ca19" integrity sha512-wciNMLg/Irp8OKGrh3S2tfvZiZ0NEyILfcRCXCD4mp7SgK/i9gzLfhY2hY7VMCQJ3kH9UB9BzNdibIVMchzyYw== -solidity-coverage@^0.8.12: - version "0.8.13" - resolved "https://registry.yarnpkg.com/solidity-coverage/-/solidity-coverage-0.8.13.tgz#8eeada2e82ae19d25568368aa782a2baad0e0ce7" - integrity sha512-RiBoI+kF94V3Rv0+iwOj3HQVSqNzA9qm/qDP1ZDXK5IX0Cvho1qiz8hAXTsAo6KOIUeP73jfscq0KlLqVxzGWA== +solidity-coverage@^0.8.17: + version "0.8.17" + resolved "https://registry.yarnpkg.com/solidity-coverage/-/solidity-coverage-0.8.17.tgz#e71df844ccf46a49b03c5ce92333a3b27597c4ae" + integrity sha512-5P8vnB6qVX9tt1MfuONtCTEaEGO/O4WuEidPHIAJjx4sktHHKhO3rFvnE0q8L30nWJPTrcqGQMT7jpE29B2qow== dependencies: "@ethersproject/abi" "^5.0.9" - "@solidity-parser/parser" "^0.18.0" + "@solidity-parser/parser" "^0.20.1" chalk "^2.4.2" death "^1.1.0" difflib "^0.2.4"