Skip to content

Commit 75748cf

Browse files
Introduces fast forwarding in L2 integration tests (#1343)
* Basic fast forwarding in L2 integration tests * Replaced 'ignore' utils with fast forwarding in integration tests * Clean install * Undo changes to package lock file * Pin ops version * Avoid redundant heartbeats * Fix and improve integration tests * Add comment to test * Update ops image * Clear ops cache in CI * Update watchers dep * Hotfix for Optimism watchers * Clean install * Update to hardhat 2.3.x * Clear ops tool cache * Unpin ops * Update ops cache * Attach ops output * Debugging Optimism messenger watchers * Listen to interactions with messenger on blocks * Keep withdraw tests open * Implementing a completely patched ops watcher * Tidy ups * remove only in tests * Disabled ops cache * Restored ops caching * Quiet * Bugfix * Debug optimism in l2 standalone integration tests * Cleanups
1 parent 708b17d commit 75748cf

32 files changed

+3329
-616
lines changed

.circleci/config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,22 @@ jobs:
5555
at: .
5656
- restore_cache:
5757
keys:
58-
- optimism-build
58+
- v2-optimism-build-
5959
- run:
6060
name: Build docker containers if necessary
6161
command: |
6262
if [ ! -d ./optimism ]; then
63-
npx hardhat ops --fresh --build --build-ops --optimism-path ./optimism
63+
npx hardhat ops --fresh --build --build-ops
6464
fi;
6565
- save_cache:
66-
key: optimism-build
66+
key: v2-optimism-build-
6767
paths:
6868
- ./optimism
6969
- run:
7070
name: Start docker chains
7171
background: true
7272
command: |
73-
npx hardhat ops --start --optimism-path ./optimism
73+
npx hardhat ops --start
7474
- cmd-wait-for-port:
7575
port: 8545
7676
- cmd-wait-for-port:

.circleci/src/jobs/job-integration-tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@ steps:
77
at: .
88
- restore_cache:
99
keys:
10-
- optimism-build
10+
- v2-optimism-build-{{ checksum "package-lock.json" }}
1111
- run:
1212
name: Build docker containers if necessary
1313
command: |
1414
if [ ! -d ./optimism ]; then
15-
npx hardhat ops --fresh --build --build-ops --optimism-path ./optimism
15+
npx hardhat ops --fresh --build --build-ops
1616
fi;
1717
- save_cache:
18-
key: optimism-build
18+
key: v2-optimism-build-{{ checksum "package-lock.json" }}
1919
paths:
2020
- ./optimism
2121
- run:
2222
name: Start docker chains
2323
background: true
2424
command: |
25-
npx hardhat ops --start --optimism-path ./optimism
25+
npx hardhat ops --start
2626
- cmd-wait-for-port:
2727
port: 8545
2828
- cmd-wait-for-port:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,5 @@ process.yml
4040
*.csv
4141

4242
.db
43+
44+
optimism

hardhat/tasks/task-ops.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,23 @@ task('ops', 'Run Optimism chain')
2020
.addFlag('start', 'Start the latest build')
2121
.addFlag('stop', 'Stop optimism chain')
2222
.addFlag('detached', 'Detach the chain from the console')
23-
.addOptionalParam('optimismPath', 'Path to optmism repository folder', '~/optimism')
23+
.addOptionalParam('optimismPath', 'Path to optmism repository folder', './optimism')
24+
.addOptionalParam('optimismBranch', 'Branch to checkout', 'master')
2425
.addOptionalParam(
2526
'optimismCommit',
2627
'Commit to checkout',
27-
undefined // Define here to pin to that specific commit
28+
'd9fd67d2502a590e116ffdb6c1c53003a045e318'
2829
)
2930
.setAction(async (taskArguments, hre, runSuper) => {
31+
taskArguments.maxMemory = true;
32+
3033
const opsPath = taskArguments.optimismPath.replace('~', homedir);
34+
const opsBranch = 'regenesis/0.4.0';
3135
const opsCommit = taskArguments.optimismCommit;
3236
const opsDetached = taskArguments.detached ? '-d' : '';
3337

38+
console.log(gray('optimism branch:', opsBranch));
39+
console.log(gray('optimism commit:', opsCommit));
3440
console.log(gray('optimism folder:', opsPath));
3541

3642
if (taskArguments.stop) {
@@ -55,14 +61,14 @@ task('ops', 'Run Optimism chain')
5561
_fresh({ opsPath });
5662
}
5763

58-
_build({ opsPath, opsCommit });
64+
_build({ opsPath, opsCommit, opsBranch });
5965
}
6066

6167
if (taskArguments.buildOps || (taskArguments.fresh && taskArguments.start)) {
6268
console.log(yellow('building ops'));
6369
if (!fs.existsSync(opsPath)) {
6470
_fresh({ opsPath });
65-
_build({ opsPath, opsCommit });
71+
_build({ opsPath, opsCommit, opsBranch });
6672
}
6773
_buildOps({ opsPath });
6874
}
@@ -76,10 +82,10 @@ task('ops', 'Run Optimism chain')
7682

7783
if (!fs.existsSync(opsPath)) {
7884
_fresh({ opsPath });
79-
_build({ opsPath, opsCommit });
85+
_build({ opsPath, opsCommit, opsBranch });
8086
_buildOps({ opsPath });
8187
} else if (!_imagesExist()) {
82-
_build({ opsPath, opsCommit });
88+
_build({ opsPath, opsCommit, opsBranch });
8389
_buildOps({ opsPath });
8490
}
8591
await _start({ opsPath, opsDetached });
@@ -135,11 +141,11 @@ function _fresh({ opsPath }) {
135141
]);
136142
}
137143

138-
function _build({ opsPath, opsCommit }) {
144+
function _build({ opsPath, opsCommit, opsBranch }) {
139145
console.log(gray(' checkout commit:', opsCommit));
140146
execa.sync('sh', ['-c', `cd ${opsPath} && git fetch `]);
141-
execa.sync('sh', ['-c', `cd ${opsPath} && git checkout master `]);
142-
execa.sync('sh', ['-c', `cd ${opsPath} && git pull origin master `]);
147+
execa.sync('sh', ['-c', `cd ${opsPath} && git checkout ${opsBranch} `]);
148+
execa.sync('sh', ['-c', `cd ${opsPath} && git pull origin ${opsBranch} `]);
143149
if (opsCommit) {
144150
execa.sync('sh', ['-c', `cd ${opsPath} && git checkout ${opsCommit}`]);
145151
}

hardhat/tasks/task-test-integration.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,18 @@ task('test:integration:l1', 'run isolated layer 1 production tests')
5454
});
5555

5656
task('test:integration:l2', 'run isolated layer 2 production tests')
57+
.addFlag('debugOptimism', 'Debug Optimism activity')
5758
.addFlag('compile', 'Compile an l2 instance before running the tests')
5859
.addFlag('deploy', 'Deploy an l2 instance before running the tests')
5960
.setAction(async (taskArguments, hre) => {
6061
hre.config.paths.tests = './test/integration/l2/';
62+
hre.config.debugOptimism = taskArguments.debugOptimism;
6163

6264
_commonIntegrationTestSettings({ hre, taskArguments });
6365

6466
const providerUrl = (hre.config.providerUrl = 'http://localhost');
65-
const providerPort = (hre.config.providerPort = '8545');
67+
hre.config.providerPortL1 = '9545';
68+
const providerPortL2 = (hre.config.providerPortL2 = '8545');
6669
const useOvm = true;
6770
const buildPath = path.join(__dirname, '..', '..', `${BUILD_FOLDER}-ovm`);
6871

@@ -74,7 +77,7 @@ task('test:integration:l2', 'run isolated layer 2 production tests')
7477
await deployInstance({
7578
useOvm,
7679
providerUrl,
77-
providerPort,
80+
providerPort: providerPortL2,
7881
buildPath,
7982
});
8083
}
@@ -83,10 +86,12 @@ task('test:integration:l2', 'run isolated layer 2 production tests')
8386
});
8487

8588
task('test:integration:dual', 'run integrated layer 1 and layer 2 production tests')
89+
.addFlag('debugOptimism', 'Debug Optimism activity')
8690
.addFlag('compile', 'Compile the l1 instance before running the tests')
8791
.addFlag('deploy', 'Deploy the l1 instance before running the tests')
8892
.setAction(async (taskArguments, hre) => {
8993
hre.config.paths.tests = './test/integration/dual/';
94+
hre.config.debugOptimism = taskArguments.debugOptimism;
9095

9196
_commonIntegrationTestSettings({ hre, taskArguments });
9297

@@ -117,7 +122,12 @@ task('test:integration:dual', 'run integrated layer 1 and layer 2 production tes
117122
});
118123
}
119124

120-
await connectInstances({ providerUrl, providerPortL1, providerPortL2 });
125+
await connectInstances({
126+
providerUrl,
127+
providerPortL1,
128+
providerPortL2,
129+
quiet: !taskArguments.debugOptimism,
130+
});
121131

122132
await hre.run('test', taskArguments);
123133
});

0 commit comments

Comments
 (0)