Skip to content
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
10 changes: 5 additions & 5 deletions .github/workflows/call.deploy-dry-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
network:
required: true
type: string
network-id:
required: true
type: string
provider-url:
required: true
type: string
Expand All @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion packages/automation-contracts/autowrap/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion packages/automation-contracts/scheduler/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
1 change: 1 addition & 0 deletions packages/ethereum-contracts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion packages/ethereum-contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion packages/ethereum-contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
6 changes: 5 additions & 1 deletion packages/ethereum-contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const config: HardhatUserConfig = {
enabled: true,
runs: 200,
},
evmVersion: "shanghai",
evmVersion: "cancun",
},
},
paths: {
Expand Down Expand Up @@ -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: {
Expand Down
9 changes: 2 additions & 7 deletions packages/ethereum-contracts/ops-scripts/libs/getConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
},
Expand Down
3 changes: 1 addition & 2 deletions packages/ethereum-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
23 changes: 17 additions & 6 deletions packages/ethereum-contracts/test/TestEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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();
Expand All @@ -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,
Expand All @@ -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);
}
Expand Down
16 changes: 7 additions & 9 deletions packages/ethereum-contracts/test/testenv-ctl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions packages/ethereum-contracts/truffle-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.

//
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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",
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/hot-fuzz/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
23 changes: 9 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
Loading