From 342319bf4ad9c5397adb15ba05822f8df726fea7 Mon Sep 17 00:00:00 2001
From: Everton Fraga <ev@ethereum.org>
Date: Thu, 12 Nov 2020 17:43:52 -0500
Subject: [PATCH 1/5] ci: on-demand testing for VM State and Blockchain

---
 .github/workflows/vm-pr.yml | 110 +++++++++++++++++++++++++++++-------
 1 file changed, 90 insertions(+), 20 deletions(-)

diff --git a/.github/workflows/vm-pr.yml b/.github/workflows/vm-pr.yml
index b079595fd4..7620ddeee0 100644
--- a/.github/workflows/vm-pr.yml
+++ b/.github/workflows/vm-pr.yml
@@ -11,7 +11,7 @@ defaults:
     working-directory: packages/vm
 
 jobs:
-  test-vm-api:
+  vm-api:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/setup-node@v1
@@ -49,21 +49,13 @@ jobs:
       - run: npm run test:API:browser
       - run: npm run lint
   
-  test-vm-state:
+  vm-state:
     runs-on: ubuntu-latest
     strategy:
       matrix:
         fork: [
-          # 'Berlin',
           'MuirGlacier',
-          'Istanbul',
-          # 'Petersburg',
-          # 'Constantinople',
-          # 'Byzantium',
-          # 'SpuriousDragon',
-          # 'TangerineWhistle',
-          # 'Homestead',
-          # 'Chainstart'
+          'Istanbul'
         ]
       fail-fast: false
     steps:
@@ -93,7 +85,48 @@ jobs:
 
       - run: npm run test:state -- --fork=${{ matrix.fork }} --verify-test-amount-alltests
 
-  test-vm-blockchain:
+  vm-state-extended:
+    if: contains(join(github.event.pull_request.labels.*.name, ' '), 'Test all hardforks')
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        fork: [
+          'Berlin',
+          'Petersburg',
+          'Constantinople',
+          'Byzantium',
+          'SpuriousDragon',
+          'TangerineWhistle',
+          'Homestead',
+          'Chainstart'
+        ]
+      fail-fast: false
+    steps:
+      - uses: actions/setup-node@v1
+        with:
+          node-version: 12.x
+      - uses: actions/checkout@v1
+
+      - name: Dependency cache
+        uses: actions/cache@v2
+        id: cache
+        with:
+          key: VM-${{ runner.os }}-12-${{ hashFiles('**/package-lock.json') }}
+          path: '**/node_modules'
+
+      # Installs root dependencies, ignoring Bootstrap All script.
+      # Bootstraps the current package only
+      - run: npm install --ignore-scripts && npm run bootstrap:vm
+        if: steps.cache.outputs.cache-hit != 'true'
+        working-directory: ${{github.workspace}}
+
+      # Builds current package and the ones it depends from.
+      - run: npm run build:vm
+        working-directory: ${{github.workspace}}
+
+      - run: npm run test:state -- --fork=${{ matrix.fork }} --verify-test-amount-alltests
+
+  vm-blockchain:
     runs-on: ubuntu-latest
     strategy:
       matrix:
@@ -102,15 +135,52 @@ jobs:
         
         # Tests were splitted with --dir and --excludeDir to balance execution times below the 9min mark.
         args: [
-          # '--fork=Berlin --expected-test-amount=33',
           '--fork=Istanbul --dir=GeneralStateTests/stTimeConsuming --expected-test-amount=15561',
-          '--fork=Istanbul --excludeDir=stTimeConsuming --expected-test-amount=19817',
-          # '--fork=Constantinople --dir=GeneralStateTests/stTimeConsuming --expected-test-amount=15561',
-          # '--fork=Constantinople --excludeDir=stTimeConsuming --expected-test-amount=17193',
-          # '--fork=Petersburg --dir=GeneralStateTests/stTimeConsuming --expected-test-amount=15561',
-          # '--fork=Petersburg --excludeDir=stTimeConsuming --expected-test-amount=17174',
-          # '--fork=Homestead --expected-test-amount=6997',
-          # '--fork=Chainstart --expected-test-amount=4385'
+          '--fork=Istanbul --excludeDir=stTimeConsuming --expected-test-amount=19817'
+        ]
+      fail-fast: false
+    steps:
+      - uses: actions/setup-node@v1
+        with:
+          node-version: 12.x
+      - uses: actions/checkout@v1
+
+      - name: Dependency cache
+        uses: actions/cache@v2
+        id: cache
+        with:
+          key: VM-${{ runner.os }}-12-${{ hashFiles('**/package-lock.json') }}
+          path: '**/node_modules'
+
+      # Installs root dependencies, ignoring Bootstrap All script.
+      # Bootstraps the current package only
+      - run: npm install --ignore-scripts && npm run bootstrap:vm
+        if: steps.cache.outputs.cache-hit != 'true'
+        working-directory: ${{github.workspace}}
+
+      # Builds current package and the ones it depends from.
+      - run: npm run build:vm
+        working-directory: ${{github.workspace}}
+
+      - run: npm run test:blockchain -- ${{ matrix.args }}
+
+  vm-blockchain-extended:
+    if: contains(join(github.event.pull_request.labels.*.name, ' '), 'Test all hardforks')
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        # Args to pass to the tester. Note that some have splitted the slow tests and only 
+        #   running those: these are only on forks where that is applicable (see PR #489 for numbers on these)
+        
+        # Tests were splitted with --dir and --excludeDir to balance execution times below the 9min mark.
+        args: [
+          '--fork=Berlin --expected-test-amount=33',
+          '--fork=Constantinople --dir=GeneralStateTests/stTimeConsuming --expected-test-amount=15561',
+          '--fork=Constantinople --excludeDir=stTimeConsuming --expected-test-amount=17193',
+          '--fork=Petersburg --dir=GeneralStateTests/stTimeConsuming --expected-test-amount=15561',
+          '--fork=Petersburg --excludeDir=stTimeConsuming --expected-test-amount=17174',
+          '--fork=Homestead --expected-test-amount=6997',
+          '--fork=Chainstart --expected-test-amount=4385'
         ]
       fail-fast: false
     steps:

From 40bdd4f9a82e921aa3124d5e79c2eb8494179e57 Mon Sep 17 00:00:00 2001
From: holgerd77 <Holger.Drewes@gmail.com>
Date: Tue, 17 Nov 2020 10:24:34 +0100
Subject: [PATCH 2/5] tests: moved ethereum-tests submodule to packages folder

---
 .gitmodules                               | 2 +-
 ethereum-tests => packages/ethereum-tests | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename ethereum-tests => packages/ethereum-tests (100%)

diff --git a/.gitmodules b/.gitmodules
index 7d7d035878..e6b8bc1676 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,4 +1,4 @@
 [submodule "ethereum-tests"]
-	path = ethereum-tests
+	path = packages/ethereum-tests
 	url = https://github.com/ethereum/tests.git
 	branch = develop
diff --git a/ethereum-tests b/packages/ethereum-tests
similarity index 100%
rename from ethereum-tests
rename to packages/ethereum-tests

From 3fb8eb55512380db3f9e8d00b55b330e68ef8a28 Mon Sep 17 00:00:00 2001
From: holgerd77 <Holger.Drewes@gmail.com>
Date: Tue, 17 Nov 2020 10:26:54 +0100
Subject: [PATCH 3/5] tests: checked out ethereumjs-testing v1.3.3
 ethereum/tests state on submodule

---
 packages/ethereum-tests | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/packages/ethereum-tests b/packages/ethereum-tests
index bfcd07f6bc..66a55cd42f 160000
--- a/packages/ethereum-tests
+++ b/packages/ethereum-tests
@@ -1 +1 @@
-Subproject commit bfcd07f6bc99ba63f33ebd4e4cfc0134de90162a
+Subproject commit 66a55cd42f63845e34767504d0a7a62b452a7e7a

From 732ea8be4819bf2f618ab32c04fee158cc206ee7 Mon Sep 17 00:00:00 2001
From: holgerd77 <Holger.Drewes@gmail.com>
Date: Tue, 17 Nov 2020 10:38:09 +0100
Subject: [PATCH 4/5] vm, tx: fixed test loader submodule paths

---
 packages/tx/test/testLoader.ts  | 2 +-
 packages/vm/tests/testLoader.ts | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/packages/tx/test/testLoader.ts b/packages/tx/test/testLoader.ts
index cc4cbc2098..31fb70fbc4 100644
--- a/packages/tx/test/testLoader.ts
+++ b/packages/tx/test/testLoader.ts
@@ -4,7 +4,7 @@ const path = require('path')
 
 const falsePredicate = () => false
 // Load tests from git submodule
-const defaultTestsPath = path.resolve('../../ethereum-tests')
+const defaultTestsPath = path.resolve('../ethereum-tests')
 /**
  * Returns the list of test files matching the given parameters
  * @param testType the test type (path segment)
diff --git a/packages/vm/tests/testLoader.ts b/packages/vm/tests/testLoader.ts
index 329e59e094..0dcc03265b 100644
--- a/packages/vm/tests/testLoader.ts
+++ b/packages/vm/tests/testLoader.ts
@@ -4,7 +4,7 @@ const path = require('path')
 
 const falsePredicate = () => false
 // Load tests from git submodule
-const defaultTestsPath = path.resolve('../../ethereum-tests')
+const defaultTestsPath = path.resolve('../ethereum-tests')
 /**
  * Returns the list of test files matching the given parameters
  * @param testType the test type (path segment)

From c0dd7ee07e45b0bf4bc2782be0b3d07dc6800d25 Mon Sep 17 00:00:00 2001
From: holgerd77 <Holger.Drewes@gmail.com>
Date: Tue, 17 Nov 2020 10:50:01 +0100
Subject: [PATCH 5/5] monorepo: fixed VM vm-blockchain, vm-state-extended
 submodule checkout

---
 .github/workflows/vm-pr.yml | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/vm-pr.yml b/.github/workflows/vm-pr.yml
index 7620ddeee0..da81a09d0c 100644
--- a/.github/workflows/vm-pr.yml
+++ b/.github/workflows/vm-pr.yml
@@ -106,7 +106,8 @@ jobs:
         with:
           node-version: 12.x
       - uses: actions/checkout@v1
-
+        with:
+          submodules: recursive
       - name: Dependency cache
         uses: actions/cache@v2
         id: cache
@@ -144,7 +145,8 @@ jobs:
         with:
           node-version: 12.x
       - uses: actions/checkout@v1
-
+        with:
+          submodules: recursive
       - name: Dependency cache
         uses: actions/cache@v2
         id: cache