Skip to content

Commit deeae86

Browse files
authored
[ETHEREUM-CONTRACTS] switch EVM target to cancun and remove ganache dependency (#2129)
* switched evm target to cancun, removed ganache dependency
1 parent b8b2bde commit deeae86

File tree

14 files changed

+56
-53
lines changed

14 files changed

+56
-53
lines changed

.github/workflows/call.deploy-dry-run.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ on:
66
network:
77
required: true
88
type: string
9-
network-id:
10-
required: true
11-
type: string
129
provider-url:
1310
required: true
1411
type: string
@@ -28,8 +25,11 @@ jobs:
2825
yarn install --frozen-lockfile
2926
yarn build-for-contracts-dev
3027
31-
- name: Start ganache
32-
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 }}
28+
- name: Start hardhat node
29+
run: |
30+
cd ${{ env.ethereum-contracts-working-directory }}
31+
npx hardhat node --port 47545 --fork ${{ github.event.inputs.provider-url }} &
32+
sleep 5
3333
3434
- name: Deploy framework
3535
run: |

packages/automation-contracts/autowrap/foundry.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ root = '../../../'
33
libs = ['lib']
44
src = 'packages/automation-contracts/autowrap'
55
solc_version = "0.8.30"
6-
evm_version = 'shanghai'
6+
evm_version = 'cancun'
77
optimizer = true
88
optimizer_runs = 200
99
remappings = [

packages/automation-contracts/scheduler/foundry.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ root = '../../../'
33
libs = ['lib']
44
src = 'packages/automation-contracts/scheduler'
55
solc_version = "0.8.30"
6-
evm_version = 'shanghai'
6+
evm_version = 'cancun'
77
optimizer = true
88
optimizer_runs = 200
99
remappings = [

packages/ethereum-contracts/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
77

88
### Changed
99

10+
- EVM target changed from _shanghai_ to _cancun_.
1011
- Update solhint to v6.
1112

1213
## [v1.14.1]

packages/ethereum-contracts/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ Run the test suite for core contracts:
355355
yarn run-hardhat test testsuites/superfluid-core.js
356356
```
357357

358-
The `pretest` script starts a ganache instance with deterministic accounts in the background, the `posttest` script stops it.
358+
The `pretest` script starts a local dev chain with deterministic accounts in the background, the `posttest` script stops it.
359359
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)).
360360
> NOTE: You don't need to run the `pretest` and `posttest` scripts when running hardhat tests, but you do when running tests with truffle.
361361

packages/ethereum-contracts/foundry.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ignored_error_codes = [
88
1699 # assembly { selfdestruct } in contracts/mocks/SuperfluidDestructorMock.sol
99
]
1010
# keep in sync with truffle-config.js
11-
evm_version = 'shanghai'
11+
evm_version = 'cancun'
1212
optimizer = true
1313
optimizer_runs = 200
1414
remappings = [

packages/ethereum-contracts/hardhat.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ const config: HardhatUserConfig = {
105105
enabled: true,
106106
runs: 200,
107107
},
108-
evmVersion: "shanghai",
108+
evmVersion: "cancun",
109109
},
110110
},
111111
paths: {
@@ -159,6 +159,10 @@ const config: HardhatUserConfig = {
159159
hardhat: {
160160
// We defer the contract size limit test to foundry.
161161
allowUnlimitedContractSize: true,
162+
// Expected by testenv-ctl.sh
163+
accounts: {
164+
mnemonic: "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat",
165+
},
162166
},
163167
},
164168
mocha: {

packages/ethereum-contracts/ops-scripts/libs/getConfig.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,8 @@ module.exports = function getConfig(chainId) {
66
// here go the trusted forwarders which aren't part of the framework contracts
77

88
// Local Testing
9-
4447: {
10-
// for local testing (truffle internal ganache and TestEnvironment)
11-
// this is a fake forwarder address, it is to test the deployment script
12-
trustedForwarders: ["0x3075b4dc7085C48A14A5A39BBa68F58B19545971"],
13-
},
14-
5777: {
15-
// for local testing (external ganache)
9+
31337: {
10+
// for local testing (hardhat node default chainId)
1611
// this is a fake forwarder address, it is to test the deployment script
1712
trustedForwarders: ["0x3075b4dc7085C48A14A5A39BBa68F58B19545971"],
1813
},

packages/ethereum-contracts/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@
2222
"async": "^3.2.6",
2323
"csv-writer": "^1.6.0",
2424
"ethers": "^5.7.2",
25-
"ganache-time-traveler": "^1.0.16",
2625
"mochawesome": "^7.1.3",
2726
"readline": "^1.3.0",
28-
"solidity-coverage": "^0.8.12",
27+
"solidity-coverage": "^0.8.17",
2928
"solidity-docgen": "^0.6.0-beta.36",
3029
"stack-trace": "0.0.10",
3130
"truffle-flattener": "^1.6.0"

packages/ethereum-contracts/test/TestEnvironment.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import {
3232

3333
const {web3tx, wad4human} = require("@decentral.ee/web3-helpers");
3434
const SuperfluidSDK = require("@superfluid-finance/js-sdk");
35-
const traveler = require("ganache-time-traveler");
3635

3736
const deployFramework = require("../ops-scripts/deploy-framework");
3837
const deploySuperToken = require("../ops-scripts/deploy-super-token");
@@ -161,6 +160,22 @@ export default class TestEnvironment {
161160
console.debug("popEvmSnapshot", JSON.stringify(this._evmSnapshots));
162161
}
163162

163+
/**
164+
* Advance time by specified seconds and mine a block (replaces ganache-time-traveler.advanceTimeAndBlock)
165+
*/
166+
async _advanceTimeAndBlock(seconds: number) {
167+
await network.provider.send("evm_increaseTime", [seconds]);
168+
await network.provider.send("evm_mine", []);
169+
}
170+
171+
/**
172+
* Set the next block's timestamp and mine a block (replaces ganache-time-traveler.advanceBlockAndSetTime)
173+
* Uses evm_mine with timestamp parameter, matching ganache-time-traveler behavior
174+
*/
175+
async _advanceBlockAndSetTime(timestamp: number) {
176+
await network.provider.send("evm_mine", [timestamp]);
177+
}
178+
164179
async useLastEvmSnapshot() {
165180
let oldEvmSnapshotId = "";
166181
const popped = this._evmSnapshots.pop();
@@ -171,10 +186,6 @@ export default class TestEnvironment {
171186
} = popped);
172187
}
173188
await this._revertToEvmSnapShot(oldEvmSnapshotId);
174-
// move the time to now
175-
await traveler.advanceBlockAndSetTime(
176-
parseInt((Date.now() / 1000).toString())
177-
);
178189
const newEvmSnapshotId = await this._takeEvmSnapshot();
179190
this._evmSnapshots.push({
180191
id: newEvmSnapshotId,
@@ -192,7 +203,7 @@ export default class TestEnvironment {
192203
const block1 = await ethers.provider.getBlock("latest");
193204
console.log("current block time", block1.timestamp);
194205
console.log(`time traveler going to the future +${jsNumTime}...`);
195-
await traveler.advanceTimeAndBlock(jsNumTime);
206+
await this._advanceTimeAndBlock(jsNumTime);
196207
const block2 = await ethers.provider.getBlock("latest");
197208
console.log("new block time", block2.timestamp);
198209
}

0 commit comments

Comments
 (0)