Commit 31845fd2 authored by Matthew Slipper's avatar Matthew Slipper Committed by GitHub

ci: Refactor dependencies to reduce runtime (#9335)

* ci: Refactor dependencies to reduce runtime

This PR makes the following changes in order to reduce CI runtime:

1. Move the long-running Cannon E2E tests into a scheduled job. This reduces E2E runtime by 8 minutes.
2. Updates the `devnet` task to leverage the contract artifacts and cannon pre-state created in order jobs. This job was also updated to use a Geth binary rather than compiling it from source. This reduces devnet runtime by 5 minutes.
3. Removes intermediate linting, allocs, and geth version check jobs by putting them all in `pnpm-monorepo`. `pnpm-monorepo` already builds the contracts, devnet allocs, and checks the Geth version in parallel so splitting these jobs out actually makes things slower due to CCI image download/environment spin-up overhead. The `pnpm-monorepo` job now plugs into a bunch of downstream jobs.
4. Refactors the action tests to take advantage of multiple test executors.
5. Swaps the `bedrock-go-tests` image to a simple CCI base image to reduce runtime (this job alone was taking ~1min due to spin up overhead).
6. Puts linting in `go-mod-download` to avoid spin-up overhead.

In sum, this PR reduces overall CI runtime from 22 minutes to ~13.

* Use develop as a trigger rather than schedule

* schedule fpp-verify
parent 5a2ac1b4
...@@ -54,6 +54,7 @@ commands: ...@@ -54,6 +54,7 @@ commands:
gcloud auth login --brief --cred-file "<< parameters.gcp_cred_config_file_path >>" gcloud auth login --brief --cred-file "<< parameters.gcp_cred_config_file_path >>"
# Configure ADC # Configure ADC
echo "export GOOGLE_APPLICATION_CREDENTIALS='<< parameters.gcp_cred_config_file_path >>'" | tee -a "$BASH_ENV" echo "export GOOGLE_APPLICATION_CREDENTIALS='<< parameters.gcp_cred_config_file_path >>'" | tee -a "$BASH_ENV"
check-changed: check-changed:
description: "Conditionally halts a step if certain modules change" description: "Conditionally halts a step if certain modules change"
parameters: parameters:
...@@ -73,6 +74,7 @@ commands: ...@@ -73,6 +74,7 @@ commands:
cd ops/check-changed cd ops/check-changed
pip3 install -r requirements.txt pip3 install -r requirements.txt
python3 main.py "<<parameters.patterns>>" python3 main.py "<<parameters.patterns>>"
notify-failures-on-develop: notify-failures-on-develop:
description: "Notify Slack" description: "Notify Slack"
parameters: parameters:
...@@ -137,15 +139,19 @@ jobs: ...@@ -137,15 +139,19 @@ jobs:
resource_class: xlarge resource_class: xlarge
steps: steps:
- checkout - checkout
- run:
name: "Check L1 geth version"
command: ./ops/scripts/geth-version-checker.sh || (echo "geth version is wrong, update ci-builder"; false)
- run: - run:
name: git submodules name: git submodules
command: make submodules command: make submodules
- check-changed:
patterns: op-chain-ops,packages/,op-node
- restore_cache: - restore_cache:
name: Restore PNPM Package Cache name: Restore PNPM Package Cache
keys: keys:
- pnpm-packages-v2-{{ checksum "pnpm-lock.yaml" }} - pnpm-packages-v2-{{ checksum "pnpm-lock.yaml" }}
- restore_cache:
name: Restore Go modules cache
key: gomod-{{ checksum "go.sum" }}
# Fetch node_modules into the pnpm store # Fetch node_modules into the pnpm store
# This will cache node_modules based on pnpm-lock so other steps can instantly install them with `pnpm install --prefer-offline` # This will cache node_modules based on pnpm-lock so other steps can instantly install them with `pnpm install --prefer-offline`
# --prefer-offline installs node_modules instantly by just reading from cache if it exists rather than fetching from network # --prefer-offline installs node_modules instantly by just reading from cache if it exists rather than fetching from network
...@@ -171,6 +177,9 @@ jobs: ...@@ -171,6 +177,9 @@ jobs:
environment: environment:
FOUNDRY_PROFILE: ci FOUNDRY_PROFILE: ci
command: pnpm build command: pnpm build
- run:
name: Generate allocs
command: make devnet-allocs
- persist_to_workspace: - persist_to_workspace:
root: "." root: "."
paths: paths:
...@@ -180,6 +189,10 @@ jobs: ...@@ -180,6 +189,10 @@ jobs:
- "packages/contracts-bedrock/forge-artifacts" - "packages/contracts-bedrock/forge-artifacts"
- "packages/contracts-bedrock/tsconfig.tsbuildinfo" - "packages/contracts-bedrock/tsconfig.tsbuildinfo"
- "packages/contracts-bedrock/tsconfig.build.tsbuildinfo" - "packages/contracts-bedrock/tsconfig.build.tsbuildinfo"
- ".devnet/allocs-l1.json"
- ".devnet/addresses.json"
- "packages/contracts-bedrock/deploy-config/devnetL1.json"
- "packages/contracts-bedrock/deployments/devnetL1"
docker-build: docker-build:
environment: environment:
...@@ -241,13 +254,6 @@ jobs: ...@@ -241,13 +254,6 @@ jobs:
- "<<parameters.release>>" - "<<parameters.release>>"
steps: steps:
- gcp-oidc-authenticate - gcp-oidc-authenticate
# Below is CircleCI recommended way of specifying nameservers on an Ubuntu box:
# https://support.circleci.com/hc/en-us/articles/7323511028251-How-to-set-custom-DNS-on-Ubuntu-based-images-using-netplan
- run: sudo sed -i '13 i \ \ \ \ \ \ \ \ \ \ \ \ nameservers:' /etc/netplan/50-cloud-init.yaml
- run: sudo sed -i '14 i \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ addresses:' /etc/netplan/50-cloud-init.yaml
- run: sudo sed -i "s/addresses:/ addresses":" [8.8.8.8, 8.8.4.4] /g" /etc/netplan/50-cloud-init.yaml
- run: cat /etc/netplan/50-cloud-init.yaml
- run: sudo netplan apply
- run: - run:
name: Build name: Build
command: | command: |
...@@ -803,6 +809,10 @@ jobs: ...@@ -803,6 +809,10 @@ jobs:
description: Number of parallel test runs description: Number of parallel test runs
type: integer type: integer
default: 6 default: 6
notify:
description: Whether to notify on failure
type: boolean
default: false
docker: docker:
- image: <<pipeline.parameters.ci_builder_image>> - image: <<pipeline.parameters.ci_builder_image>>
resource_class: xlarge resource_class: xlarge
...@@ -819,6 +829,12 @@ jobs: ...@@ -819,6 +829,12 @@ jobs:
- run: - run:
name: prep results dir name: prep results dir
command: mkdir -p /tmp/test-results command: mkdir -p /tmp/test-results
- restore_cache:
name: Restore Go modules cache
key: gomod-{{ checksum "go.sum" }}
- restore_cache:
name: Restore Go build cache
key: golang-build-cache
- attach_workspace: - attach_workspace:
at: /tmp/workspace at: /tmp/workspace
- run: - run:
...@@ -851,6 +867,10 @@ jobs: ...@@ -851,6 +867,10 @@ jobs:
when: always when: always
- store_test_results: - store_test_results:
path: /tmp/test-results path: /tmp/test-results
- when:
condition: "<<parameters.notify>>"
steps:
- notify-failures-on-develop
go-lint-test-build: go-lint-test-build:
parameters: parameters:
...@@ -1015,6 +1035,14 @@ jobs: ...@@ -1015,6 +1035,14 @@ jobs:
sudo tar -C /usr/local -xzf go1.21.1.linux-amd64.tar.gz sudo tar -C /usr/local -xzf go1.21.1.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin export PATH=$PATH:/usr/local/go/bin
go version go version
- run:
name: Install Geth
command: |
wget https://gethstore.blob.core.windows.net/builds/geth-alltools-linux-amd64-1.13.4-3f907d6a.tar.gz
# geth only provides md5 sums sadly
echo 'c2e3d38372cb8081ed01591246a7556f geth-alltools-linux-amd64-1.13.4-3f907d6a.tar.gz' | md5sum -c -
tar -xzvf geth-alltools-linux-amd64-1.13.4-3f907d6a.tar.gz
sudo cp geth-alltools-linux-amd64-1.13.4-3f907d6a/* /usr/local/bin
- run: - run:
name: foundryup name: foundryup
command: | command: |
...@@ -1042,44 +1070,31 @@ jobs: ...@@ -1042,44 +1070,31 @@ jobs:
- run: - run:
name: git submodules name: git submodules
command: make submodules command: make submodules
- run:
name: Install and build
command: |
pnpm install:ci && pnpm build
- attach_workspace: - attach_workspace:
at: /tmp/workspace at: "."
- run:
name: Load cannon pre-state
command: |
mkdir -p op-program/bin
cp /tmp/workspace/op-program/bin/prestate.json op-program/bin/prestate.json
cp /tmp/workspace/op-program/bin/meta.json op-program/bin/meta.json
cp /tmp/workspace/op-program/bin/prestate-proof.json op-program/bin/prestate-proof.json
- run:
name: Load devnet-allocs
command: |
mkdir -p .devnet
cp /tmp/workspace/.devnet/allocs-l1.json .devnet/allocs-l1.json
cp /tmp/workspace/.devnet/addresses.json .devnet/addresses.json
cp /tmp/workspace/packages/contracts-bedrock/deploy-config/devnetL1.json packages/contracts-bedrock/deploy-config/devnetL1.json
cp -r /tmp/workspace/packages/contracts-bedrock/deployments/devnetL1 packages/contracts-bedrock/deployments/devnetL1
- run: - run:
name: Load and tag docker images name: Load and tag docker images
command: | command: |
IMAGE_BASE_PREFIX="us-docker.pkg.dev/oplabs-tools-artifacts/images" IMAGE_BASE_PREFIX="us-docker.pkg.dev/oplabs-tools-artifacts/images"
# Load from previous docker-build job # Load from previous docker-build job
docker load < "/tmp/workspace/op-stack-go.tar" docker load < "./op-stack-go.tar"
docker load < "/tmp/workspace/op-node.tar" docker load < "./op-node.tar"
docker load < "/tmp/workspace/op-proposer.tar" docker load < "./op-proposer.tar"
docker load < "/tmp/workspace/op-batcher.tar" docker load < "./op-batcher.tar"
# rename to the tags that the docker-compose of the devnet expects # rename to the tags that the docker-compose of the devnet expects
docker tag "$IMAGE_BASE_PREFIX/op-stack-go:<<pipeline.git.revision>>" "$IMAGE_BASE_PREFIX/op-stack-go:devnet" docker tag "$IMAGE_BASE_PREFIX/op-stack-go:<<pipeline.git.revision>>" "$IMAGE_BASE_PREFIX/op-stack-go:devnet"
docker tag "$IMAGE_BASE_PREFIX/op-node:<<pipeline.git.revision>>" "$IMAGE_BASE_PREFIX/op-node:devnet" docker tag "$IMAGE_BASE_PREFIX/op-node:<<pipeline.git.revision>>" "$IMAGE_BASE_PREFIX/op-node:devnet"
docker tag "$IMAGE_BASE_PREFIX/op-proposer:<<pipeline.git.revision>>" "$IMAGE_BASE_PREFIX/op-proposer:devnet" docker tag "$IMAGE_BASE_PREFIX/op-proposer:<<pipeline.git.revision>>" "$IMAGE_BASE_PREFIX/op-proposer:devnet"
docker tag "$IMAGE_BASE_PREFIX/op-batcher:<<pipeline.git.revision>>" "$IMAGE_BASE_PREFIX/op-batcher:devnet" docker tag "$IMAGE_BASE_PREFIX/op-batcher:<<pipeline.git.revision>>" "$IMAGE_BASE_PREFIX/op-batcher:devnet"
- run:
name: pnpm i
command: |
pnpm i && pnpm build
- run: - run:
name: Bring up the stack name: Bring up the stack
command: make devnet-up command: |
# Specify like this to avoid a forced rebuild of the contracts + devnet L1
PYTHONPATH=./bedrock-devnet python3 ./bedrock-devnet/main.py --monorepo-dir=.
- run: - run:
name: Test the stack name: Test the stack
command: make devnet-test command: make devnet-test
...@@ -1184,6 +1199,16 @@ jobs: ...@@ -1184,6 +1199,16 @@ jobs:
- run: - run:
command: go mod download command: go mod download
name: Download Go module dependencies name: Download Go module dependencies
- run:
name: "Go mod tidy"
command: make mod-tidy && git diff --exit-code
- run:
name: run Go linter
command: |
# Identify how many cores it defaults to
golangci-lint --help | grep concurrency
make lint-go
working_directory: .
- save_cache: - save_cache:
key: << parameters.key >>-{{ checksum "<< parameters.file >>" }} key: << parameters.key >>-{{ checksum "<< parameters.file >>" }}
name: Save Go modules cache name: Save Go modules cache
...@@ -1243,7 +1268,10 @@ jobs: ...@@ -1243,7 +1268,10 @@ jobs:
bedrock-go-tests: # just a helper, that depends on all the actual test jobs bedrock-go-tests: # just a helper, that depends on all the actual test jobs
docker: docker:
- image: <<pipeline.parameters.ci_builder_image>> # Use a smaller base image to avoid pulling the huge ci-builder
# image which is not needed for this job and sometimes misses
# the cache.
- image: cimg/base:2024.01
resource_class: medium resource_class: medium
steps: steps:
- run: echo Done - run: echo Done
...@@ -1349,7 +1377,8 @@ workflows: ...@@ -1349,7 +1377,8 @@ workflows:
not: not:
equal: [ scheduled_pipeline, << pipeline.trigger_source >> ] equal: [ scheduled_pipeline, << pipeline.trigger_source >> ]
jobs: jobs:
- pnpm-monorepo - pnpm-monorepo:
name: pnpm-monorepo
- js-lint-test: - js-lint-test:
name: common-ts-tests name: common-ts-tests
coverage_flag: common-ts-tests coverage_flag: common-ts-tests
...@@ -1409,131 +1438,118 @@ workflows: ...@@ -1409,131 +1438,118 @@ workflows:
binary_name: proxyd binary_name: proxyd
working_directory: proxyd working_directory: proxyd
- indexer-tests - indexer-tests
- l1-geth-version-check
- semgrep-scan - semgrep-scan
- go-mod-download - go-mod-download
- go-mod-tidy:
requires: ["go-mod-download"]
- devnet-allocs: # devnet-allocs uses op-node genesis sub-command
requires:
- "go-mod-tidy"
- l1-geth-version-check
- go-lint: # we combine most of the go-lint work for two reasons: (1) warm up the Go build cache, (2) reduce sum of lint time
name: op-stack-go-lint
requires: [ "go-mod-tidy" ]
- fuzz-golang: - fuzz-golang:
name: op-challenger-fuzz name: op-challenger-fuzz
package_name: op-challenger package_name: op-challenger
on_changes: op-challenger on_changes: op-challenger
requires: ["op-stack-go-lint"] requires: ["go-mod-download"]
- fuzz-golang: - fuzz-golang:
name: op-node-fuzz name: op-node-fuzz
package_name: op-node package_name: op-node
on_changes: op-node on_changes: op-node
requires: ["op-stack-go-lint"] requires: ["go-mod-download"]
- fuzz-golang: - fuzz-golang:
name: op-service-fuzz name: op-service-fuzz
package_name: op-service package_name: op-service
on_changes: op-service on_changes: op-service
requires: ["op-stack-go-lint"] requires: ["go-mod-download"]
- fuzz-golang: - fuzz-golang:
name: op-chain-ops-fuzz name: op-chain-ops-fuzz
package_name: op-chain-ops package_name: op-chain-ops
on_changes: op-chain-ops,op-bindings on_changes: op-chain-ops,op-bindings
requires: ["op-stack-go-lint"] requires: ["go-mod-download"]
- fuzz-golang: - fuzz-golang:
name: cannon-fuzz name: cannon-fuzz
package_name: cannon package_name: cannon
on_changes: cannon,packages/contracts-bedrock/src/cannon on_changes: cannon,packages/contracts-bedrock/src/cannon
requires: ["op-stack-go-lint"] requires: ["go-mod-download"]
- go-test: - go-test:
name: op-heartbeat-tests name: op-heartbeat-tests
module: op-heartbeat module: op-heartbeat
requires: [ "op-stack-go-lint" ] requires: [ "go-mod-download" ]
- go-test: - go-test:
name: op-batcher-tests name: op-batcher-tests
module: op-batcher module: op-batcher
requires: ["op-stack-go-lint"] requires: ["go-mod-download"]
- go-test: - go-test:
name: op-bindings-tests name: op-bindings-tests
module: op-bindings module: op-bindings
requires: ["op-stack-go-lint"] requires: ["go-mod-download"]
- go-test: - go-test:
name: op-chain-ops-tests name: op-chain-ops-tests
module: op-chain-ops module: op-chain-ops
requires: ["op-stack-go-lint"] requires: ["go-mod-download"]
- go-test: - go-test:
name: op-node-tests name: op-node-tests
module: op-node module: op-node
requires: ["op-stack-go-lint"] requires: ["go-mod-download"]
- go-test: - go-test:
name: op-proposer-tests name: op-proposer-tests
module: op-proposer module: op-proposer
requires: ["op-stack-go-lint"] requires: ["go-mod-download"]
- go-test: - go-test:
name: op-challenger-tests name: op-challenger-tests
module: op-challenger module: op-challenger
requires: ["op-stack-go-lint"] requires: ["go-mod-download"]
- go-test: - go-test:
name: op-conductor-tests name: op-conductor-tests
module: op-conductor module: op-conductor
requires: ["op-stack-go-lint"] requires: ["go-mod-download"]
- go-test: - go-test:
name: op-program-tests name: op-program-tests
module: op-program module: op-program
requires: ["op-stack-go-lint"] requires: ["go-mod-download"]
- go-test: - go-test:
name: op-service-tests name: op-service-tests
module: op-service module: op-service
requires: ["op-stack-go-lint"] requires: ["go-mod-download"]
- op-service-rethdb-tests: - op-service-rethdb-tests:
requires: requires:
- op-stack-go-lint - go-mod-download
- go-e2e-test: - go-e2e-test:
name: op-e2e-HTTP-tests name: op-e2e-HTTP-tests
module: op-e2e module: op-e2e
target: test-http target: test-http
parallelism: 4 parallelism: 4
requires: requires:
- op-stack-go-lint - go-mod-download
- devnet-allocs - pnpm-monorepo
- go-e2e-test: - go-e2e-test:
name: op-e2e-action-tests name: op-e2e-action-tests
module: op-e2e module: op-e2e
target: test-actions target: test-actions
parallelism: 1 parallelism: 1
requires: requires:
- op-stack-go-lint - go-mod-download
- devnet-allocs - pnpm-monorepo
- go-e2e-test: - go-e2e-test:
name: op-e2e-cannon-tests name: op-e2e-fault-proof-tests
module: op-e2e module: op-e2e
target: test-cannon target: test-fault-proofs
parallelism: 8 parallelism: 4
requires: requires:
- op-stack-go-lint - pnpm-monorepo
- devnet-allocs
- cannon-prestate - cannon-prestate
- go-e2e-test: - go-e2e-test:
name: op-e2e-ext-geth-tests name: op-e2e-ext-geth-tests
module: op-e2e module: op-e2e
target: test-external-geth target: test-external-geth
requires: requires:
- op-stack-go-lint - go-mod-download
- devnet-allocs - pnpm-monorepo
- l1-geth-version-check
- op-program-compat: - op-program-compat:
requires: requires:
- op-program-tests - op-program-tests
- bedrock-go-tests: - bedrock-go-tests:
requires: requires:
- go-mod-download - go-mod-download
- go-mod-tidy
- cannon-build-test-vectors - cannon-build-test-vectors
- cannon-go-lint-and-test - cannon-go-lint-and-test
- check-generated-mocks-op-node - check-generated-mocks-op-node
- check-generated-mocks-op-service - check-generated-mocks-op-service
- op-stack-go-lint - go-mod-download
- op-batcher-tests - op-batcher-tests
- op-bindings-tests - op-bindings-tests
- op-chain-ops-tests - op-chain-ops-tests
...@@ -1546,7 +1562,7 @@ workflows: ...@@ -1546,7 +1562,7 @@ workflows:
- op-program-compat - op-program-compat
- op-service-tests - op-service-tests
- op-e2e-HTTP-tests - op-e2e-HTTP-tests
- op-e2e-cannon-tests - op-e2e-fault-proof-tests
- op-e2e-action-tests - op-e2e-action-tests
- op-e2e-ext-geth-tests - op-e2e-ext-geth-tests
- op-service-rethdb-tests - op-service-rethdb-tests
...@@ -1598,14 +1614,14 @@ workflows: ...@@ -1598,14 +1614,14 @@ workflows:
requires: ['op-stack-go-docker-build'] requires: ['op-stack-go-docker-build']
save_image_tag: <<pipeline.git.revision>> # for devnet later save_image_tag: <<pipeline.git.revision>> # for devnet later
- cannon-prestate: - cannon-prestate:
requires: ["op-stack-go-lint"] requires:
- go-mod-download
- devnet: - devnet:
requires: requires:
- op-node-docker-build - pnpm-monorepo
- op-batcher-docker-build - op-batcher-docker-build
- op-proposer-docker-build - op-proposer-docker-build
- l1-geth-version-check - op-node-docker-build
- devnet-allocs
- cannon-prestate - cannon-prestate
- docker-build: - docker-build:
name: indexer-docker-build name: indexer-docker-build
...@@ -1851,6 +1867,30 @@ workflows: ...@@ -1851,6 +1867,30 @@ workflows:
- slack - slack
- oplabs-fpp-nodes - oplabs-fpp-nodes
develop-fault-proofs:
when:
equal: [ "develop", <<pipeline.git.branch>> ]
jobs:
- go-mod-download
- cannon-prestate:
requires:
- go-mod-download
- pnpm-monorepo:
name: pnpm-monorepo
requires:
- go-mod-download
- go-e2e-test:
name: op-e2e-cannon-tests
module: op-e2e
target: test-cannon
parallelism: 4
notify: true
requires:
- pnpm-monorepo
- cannon-prestate
context:
- slack
scheduled-kontrol-tests: scheduled-kontrol-tests:
when: when:
equal: [ build_four_hours, <<pipeline.schedule.name>> ] equal: [ build_four_hours, <<pipeline.schedule.name>> ]
......
...@@ -29,6 +29,11 @@ test-http: pre-test ...@@ -29,6 +29,11 @@ test-http: pre-test
test-cannon: pre-test test-cannon: pre-test
OP_E2E_CANNON_ENABLED=true $(go_test) $(go_test_flags) ./faultproofs OP_E2E_CANNON_ENABLED=true $(go_test) $(go_test_flags) ./faultproofs
.PHONY: test-cannon
test-fault-proofs: pre-test
$(go_test) $(go_test_flags) ./faultproofs
.PHONY: test-faultproofs
cannon-prestate: cannon-prestate:
make -C .. cannon-prestate make -C .. cannon-prestate
......
...@@ -2,26 +2,12 @@ package actions ...@@ -2,26 +2,12 @@ package actions
import ( import (
"context" "context"
"os"
op_e2e "github.com/ethereum-optimism/optimism/op-e2e"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils" "github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
) )
var enableParallelTesting bool = true
func init() {
if os.Getenv("OP_E2E_DISABLE_PARALLEL") == "true" {
enableParallelTesting = false
}
}
func parallel(t e2eutils.TestingBase) {
t.Helper()
if enableParallelTesting {
t.Parallel()
}
}
// Testing is an interface to Go-like testing, // Testing is an interface to Go-like testing,
// extended with a context getter for the test runner to shut down individual actions without interrupting the test, // extended with a context getter for the test runner to shut down individual actions without interrupting the test,
// and a signaling function for when an invalid action is hit. // and a signaling function for when an invalid action is hit.
...@@ -69,7 +55,8 @@ type StatefulTesting interface { ...@@ -69,7 +55,8 @@ type StatefulTesting interface {
// NewDefaultTesting returns a new testing obj, and enables parallel test execution. // NewDefaultTesting returns a new testing obj, and enables parallel test execution.
// Returns an interface, we're likely changing the behavior here as we build more action tests. // Returns an interface, we're likely changing the behavior here as we build more action tests.
func NewDefaultTesting(tb e2eutils.TestingBase) StatefulTesting { func NewDefaultTesting(tb e2eutils.TestingBase) StatefulTesting {
parallel(tb) op_e2e.InitParallel(tb)
return &defaultTesting{ return &defaultTesting{
TestingBase: tb, TestingBase: tb,
ctx: context.Background(), ctx: context.Background(),
......
...@@ -11,7 +11,7 @@ import ( ...@@ -11,7 +11,7 @@ import (
) )
func TestMultipleGameTypes(t *testing.T) { func TestMultipleGameTypes(t *testing.T) {
op_e2e.InitParallel(t, op_e2e.UsesCannon, op_e2e.UseExecutor(0)) op_e2e.InitParallel(t, op_e2e.UsesCannon)
ctx := context.Background() ctx := context.Background()
sys, _ := startFaultDisputeSystem(t) sys, _ := startFaultDisputeSystem(t)
......
...@@ -14,7 +14,7 @@ import ( ...@@ -14,7 +14,7 @@ import (
) )
func TestOutputAlphabetGame_ChallengerWins(t *testing.T) { func TestOutputAlphabetGame_ChallengerWins(t *testing.T) {
op_e2e.InitParallel(t, op_e2e.UseExecutor(1)) op_e2e.InitParallel(t)
ctx := context.Background() ctx := context.Background()
sys, l1Client := startFaultDisputeSystem(t) sys, l1Client := startFaultDisputeSystem(t)
t.Cleanup(sys.Close) t.Cleanup(sys.Close)
...@@ -71,7 +71,7 @@ func TestOutputAlphabetGame_ChallengerWins(t *testing.T) { ...@@ -71,7 +71,7 @@ func TestOutputAlphabetGame_ChallengerWins(t *testing.T) {
} }
func TestOutputAlphabetGame_ValidOutputRoot(t *testing.T) { func TestOutputAlphabetGame_ValidOutputRoot(t *testing.T) {
op_e2e.InitParallel(t, op_e2e.UseExecutor(1)) op_e2e.InitParallel(t)
ctx := context.Background() ctx := context.Background()
sys, l1Client := startFaultDisputeSystem(t) sys, l1Client := startFaultDisputeSystem(t)
t.Cleanup(sys.Close) t.Cleanup(sys.Close)
...@@ -102,7 +102,7 @@ func TestOutputAlphabetGame_ValidOutputRoot(t *testing.T) { ...@@ -102,7 +102,7 @@ func TestOutputAlphabetGame_ValidOutputRoot(t *testing.T) {
} }
func TestChallengerCompleteExhaustiveDisputeGame(t *testing.T) { func TestChallengerCompleteExhaustiveDisputeGame(t *testing.T) {
op_e2e.InitParallel(t, op_e2e.UseExecutor(1)) op_e2e.InitParallel(t)
testCase := func(t *testing.T, isRootCorrect bool) { testCase := func(t *testing.T, isRootCorrect bool) {
ctx := context.Background() ctx := context.Background()
...@@ -159,11 +159,11 @@ func TestChallengerCompleteExhaustiveDisputeGame(t *testing.T) { ...@@ -159,11 +159,11 @@ func TestChallengerCompleteExhaustiveDisputeGame(t *testing.T) {
} }
t.Run("RootCorrect", func(t *testing.T) { t.Run("RootCorrect", func(t *testing.T) {
op_e2e.InitParallel(t, op_e2e.UseExecutor(1)) op_e2e.InitParallel(t)
testCase(t, true) testCase(t, true)
}) })
t.Run("RootIncorrect", func(t *testing.T) { t.Run("RootIncorrect", func(t *testing.T) {
op_e2e.InitParallel(t, op_e2e.UseExecutor(1)) op_e2e.InitParallel(t)
testCase(t, false) testCase(t, false)
}) })
} }
...@@ -16,7 +16,7 @@ import ( ...@@ -16,7 +16,7 @@ import (
) )
func TestOutputCannonGame(t *testing.T) { func TestOutputCannonGame(t *testing.T) {
op_e2e.InitParallel(t, op_e2e.UsesCannon, op_e2e.UseExecutor(0)) op_e2e.InitParallel(t, op_e2e.UsesCannon)
ctx := context.Background() ctx := context.Background()
sys, l1Client := startFaultDisputeSystem(t) sys, l1Client := startFaultDisputeSystem(t)
t.Cleanup(sys.Close) t.Cleanup(sys.Close)
...@@ -72,7 +72,7 @@ func TestOutputCannonGame(t *testing.T) { ...@@ -72,7 +72,7 @@ func TestOutputCannonGame(t *testing.T) {
func TestOutputCannon_ChallengeAllZeroClaim(t *testing.T) { func TestOutputCannon_ChallengeAllZeroClaim(t *testing.T) {
// The dishonest actor always posts claims with all zeros. // The dishonest actor always posts claims with all zeros.
op_e2e.InitParallel(t, op_e2e.UsesCannon, op_e2e.UseExecutor(1)) op_e2e.InitParallel(t, op_e2e.UsesCannon)
ctx := context.Background() ctx := context.Background()
sys, l1Client := startFaultDisputeSystem(t) sys, l1Client := startFaultDisputeSystem(t)
t.Cleanup(sys.Close) t.Cleanup(sys.Close)
...@@ -109,7 +109,7 @@ func TestOutputCannon_PublishCannonRootClaim(t *testing.T) { ...@@ -109,7 +109,7 @@ func TestOutputCannon_PublishCannonRootClaim(t *testing.T) {
for _, test := range tests { for _, test := range tests {
test := test test := test
t.Run(fmt.Sprintf("Dispute_%v", test.disputeL2BlockNumber), func(t *testing.T) { t.Run(fmt.Sprintf("Dispute_%v", test.disputeL2BlockNumber), func(t *testing.T) {
op_e2e.InitParallel(t, op_e2e.UsesCannon, op_e2e.UseExecutor(2)) op_e2e.InitParallel(t, op_e2e.UsesCannon)
ctx := context.Background() ctx := context.Background()
sys, _ := startFaultDisputeSystem(t) sys, _ := startFaultDisputeSystem(t)
...@@ -139,7 +139,7 @@ func TestOutputCannonDisputeGame(t *testing.T) { ...@@ -139,7 +139,7 @@ func TestOutputCannonDisputeGame(t *testing.T) {
for _, test := range tests { for _, test := range tests {
test := test test := test
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
op_e2e.InitParallel(t, op_e2e.UsesCannon, op_e2e.UseExecutor(3)) op_e2e.InitParallel(t, op_e2e.UsesCannon)
ctx := context.Background() ctx := context.Background()
sys, l1Client := startFaultDisputeSystem(t) sys, l1Client := startFaultDisputeSystem(t)
...@@ -176,7 +176,7 @@ func TestOutputCannonDisputeGame(t *testing.T) { ...@@ -176,7 +176,7 @@ func TestOutputCannonDisputeGame(t *testing.T) {
} }
func TestOutputCannonDefendStep(t *testing.T) { func TestOutputCannonDefendStep(t *testing.T) {
op_e2e.InitParallel(t, op_e2e.UsesCannon, op_e2e.UseExecutor(4)) op_e2e.InitParallel(t, op_e2e.UsesCannon)
ctx := context.Background() ctx := context.Background()
sys, l1Client := startFaultDisputeSystem(t) sys, l1Client := startFaultDisputeSystem(t)
...@@ -212,7 +212,7 @@ func TestOutputCannonDefendStep(t *testing.T) { ...@@ -212,7 +212,7 @@ func TestOutputCannonDefendStep(t *testing.T) {
} }
func TestOutputCannonStepWithLargePreimage(t *testing.T) { func TestOutputCannonStepWithLargePreimage(t *testing.T) {
op_e2e.InitParallel(t, op_e2e.UsesCannon, op_e2e.UseExecutor(0)) op_e2e.InitParallel(t, op_e2e.UsesCannon)
ctx := context.Background() ctx := context.Background()
sys, _ := startFaultDisputeSystem(t, withLargeBatches()) sys, _ := startFaultDisputeSystem(t, withLargeBatches())
...@@ -258,7 +258,7 @@ func TestOutputCannonStepWithLargePreimage(t *testing.T) { ...@@ -258,7 +258,7 @@ func TestOutputCannonStepWithLargePreimage(t *testing.T) {
func TestOutputCannonStepWithPreimage(t *testing.T) { func TestOutputCannonStepWithPreimage(t *testing.T) {
testPreimageStep := func(t *testing.T, preloadPreimage bool) { testPreimageStep := func(t *testing.T, preloadPreimage bool) {
op_e2e.InitParallel(t, op_e2e.UsesCannon, op_e2e.UseExecutor(5)) op_e2e.InitParallel(t, op_e2e.UsesCannon)
ctx := context.Background() ctx := context.Background()
sys, l1Client := startFaultDisputeSystem(t) sys, l1Client := startFaultDisputeSystem(t)
...@@ -315,9 +315,6 @@ func TestOutputCannonProposedOutputRootValid(t *testing.T) { ...@@ -315,9 +315,6 @@ func TestOutputCannonProposedOutputRootValid(t *testing.T) {
// performStep is called once the maximum game depth is reached. It should perform a step to counter the // performStep is called once the maximum game depth is reached. It should perform a step to counter the
// claim at parentClaimIdx. Since the proposed output root is invalid, the step call should always revert. // claim at parentClaimIdx. Since the proposed output root is invalid, the step call should always revert.
performStep func(ctx context.Context, game *disputegame.OutputCannonGameHelper, correctTrace *disputegame.OutputHonestHelper, parentClaimIdx int64) performStep func(ctx context.Context, game *disputegame.OutputCannonGameHelper, correctTrace *disputegame.OutputHonestHelper, parentClaimIdx int64)
// executor to run the task on
executor uint64
}{ }{
{ {
name: "AttackWithCorrectTrace", name: "AttackWithCorrectTrace",
...@@ -330,7 +327,6 @@ func TestOutputCannonProposedOutputRootValid(t *testing.T) { ...@@ -330,7 +327,6 @@ func TestOutputCannonProposedOutputRootValid(t *testing.T) {
return correctTrace.AttackClaim(ctx, claim) return correctTrace.AttackClaim(ctx, claim)
}, },
performStep: honestStepsFail, performStep: honestStepsFail,
executor: 6,
}, },
{ {
name: "DefendWithCorrectTrace", name: "DefendWithCorrectTrace",
...@@ -349,14 +345,13 @@ func TestOutputCannonProposedOutputRootValid(t *testing.T) { ...@@ -349,14 +345,13 @@ func TestOutputCannonProposedOutputRootValid(t *testing.T) {
return correctTrace.DefendClaim(ctx, claim) return correctTrace.DefendClaim(ctx, claim)
}, },
performStep: honestStepsFail, performStep: honestStepsFail,
executor: 7,
}, },
} }
for _, test := range tests { for _, test := range tests {
test := test test := test
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
op_e2e.InitParallel(t, op_e2e.UsesCannon, op_e2e.UseExecutor(test.executor)) op_e2e.InitParallel(t, op_e2e.UsesCannon)
ctx := context.Background() ctx := context.Background()
sys, l1Client := startFaultDisputeSystem(t) sys, l1Client := startFaultDisputeSystem(t)
...@@ -390,7 +385,7 @@ func TestOutputCannonProposedOutputRootValid(t *testing.T) { ...@@ -390,7 +385,7 @@ func TestOutputCannonProposedOutputRootValid(t *testing.T) {
} }
func TestOutputCannonPoisonedPostState(t *testing.T) { func TestOutputCannonPoisonedPostState(t *testing.T) {
op_e2e.InitParallel(t, op_e2e.UsesCannon, op_e2e.UseExecutor(1)) op_e2e.InitParallel(t, op_e2e.UsesCannon)
ctx := context.Background() ctx := context.Background()
sys, l1Client := startFaultDisputeSystem(t) sys, l1Client := startFaultDisputeSystem(t)
...@@ -454,7 +449,7 @@ func TestOutputCannonPoisonedPostState(t *testing.T) { ...@@ -454,7 +449,7 @@ func TestOutputCannonPoisonedPostState(t *testing.T) {
} }
func TestDisputeOutputRootBeyondProposedBlock_ValidOutputRoot(t *testing.T) { func TestDisputeOutputRootBeyondProposedBlock_ValidOutputRoot(t *testing.T) {
op_e2e.InitParallel(t, op_e2e.UsesCannon, op_e2e.UseExecutor(2)) op_e2e.InitParallel(t, op_e2e.UsesCannon)
ctx := context.Background() ctx := context.Background()
sys, l1Client := startFaultDisputeSystem(t) sys, l1Client := startFaultDisputeSystem(t)
...@@ -504,7 +499,7 @@ func TestDisputeOutputRootBeyondProposedBlock_ValidOutputRoot(t *testing.T) { ...@@ -504,7 +499,7 @@ func TestDisputeOutputRootBeyondProposedBlock_ValidOutputRoot(t *testing.T) {
} }
func TestDisputeOutputRootBeyondProposedBlock_InvalidOutputRoot(t *testing.T) { func TestDisputeOutputRootBeyondProposedBlock_InvalidOutputRoot(t *testing.T) {
op_e2e.InitParallel(t, op_e2e.UsesCannon, op_e2e.UseExecutor(3)) op_e2e.InitParallel(t, op_e2e.UsesCannon)
ctx := context.Background() ctx := context.Background()
sys, l1Client := startFaultDisputeSystem(t) sys, l1Client := startFaultDisputeSystem(t)
...@@ -555,7 +550,7 @@ func TestDisputeOutputRootBeyondProposedBlock_InvalidOutputRoot(t *testing.T) { ...@@ -555,7 +550,7 @@ func TestDisputeOutputRootBeyondProposedBlock_InvalidOutputRoot(t *testing.T) {
} }
func TestDisputeOutputRoot_ChangeClaimedOutputRoot(t *testing.T) { func TestDisputeOutputRoot_ChangeClaimedOutputRoot(t *testing.T) {
op_e2e.InitParallel(t, op_e2e.UsesCannon, op_e2e.UseExecutor(4)) op_e2e.InitParallel(t, op_e2e.UsesCannon)
ctx := context.Background() ctx := context.Background()
sys, l1Client := startFaultDisputeSystem(t) sys, l1Client := startFaultDisputeSystem(t)
......
...@@ -4,7 +4,8 @@ import ( ...@@ -4,7 +4,8 @@ import (
"crypto/md5" "crypto/md5"
"os" "os"
"strconv" "strconv"
"testing"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
) )
var enableParallelTesting bool = os.Getenv("OP_E2E_DISABLE_PARALLEL") != "true" var enableParallelTesting bool = os.Getenv("OP_E2E_DISABLE_PARALLEL") != "true"
...@@ -13,7 +14,7 @@ type testopts struct { ...@@ -13,7 +14,7 @@ type testopts struct {
executor uint64 executor uint64
} }
func InitParallel(t *testing.T, args ...func(t *testing.T, opts *testopts)) { func InitParallel(t e2eutils.TestingBase, args ...func(t e2eutils.TestingBase, opts *testopts)) {
t.Helper() t.Helper()
if enableParallelTesting { if enableParallelTesting {
t.Parallel() t.Parallel()
...@@ -32,7 +33,7 @@ func InitParallel(t *testing.T, args ...func(t *testing.T, opts *testopts)) { ...@@ -32,7 +33,7 @@ func InitParallel(t *testing.T, args ...func(t *testing.T, opts *testopts)) {
checkExecutor(t, info, opts.executor) checkExecutor(t, info, opts.executor)
} }
func UsesCannon(t *testing.T, opts *testopts) { func UsesCannon(t e2eutils.TestingBase, opts *testopts) {
if os.Getenv("OP_E2E_CANNON_ENABLED") == "false" { if os.Getenv("OP_E2E_CANNON_ENABLED") == "false" {
t.Skip("Skipping cannon test") t.Skip("Skipping cannon test")
} }
...@@ -44,8 +45,8 @@ func UsesCannon(t *testing.T, opts *testopts) { ...@@ -44,8 +45,8 @@ func UsesCannon(t *testing.T, opts *testopts) {
// InitParallel(t, UseExecutor(1)) // InitParallel(t, UseExecutor(1))
// Any tests assigned to an executor greater than the number available automatically use the last executor. // Any tests assigned to an executor greater than the number available automatically use the last executor.
// Executor indexes start from 0 // Executor indexes start from 0
func UseExecutor(assignedIdx uint64) func(t *testing.T, opts *testopts) { func UseExecutor(assignedIdx uint64) func(t e2eutils.TestingBase, opts *testopts) {
return func(t *testing.T, opts *testopts) { return func(t e2eutils.TestingBase, opts *testopts) {
opts.executor = assignedIdx opts.executor = assignedIdx
} }
} }
...@@ -56,7 +57,7 @@ type executorInfo struct { ...@@ -56,7 +57,7 @@ type executorInfo struct {
splitInUse bool splitInUse bool
} }
func getExecutorInfo(t *testing.T) executorInfo { func getExecutorInfo(t e2eutils.TestingBase) executorInfo {
var info executorInfo var info executorInfo
envTotal := os.Getenv("CIRCLE_NODE_TOTAL") envTotal := os.Getenv("CIRCLE_NODE_TOTAL")
envIdx := os.Getenv("CIRCLE_NODE_INDEX") envIdx := os.Getenv("CIRCLE_NODE_INDEX")
...@@ -81,7 +82,7 @@ func getExecutorInfo(t *testing.T) executorInfo { ...@@ -81,7 +82,7 @@ func getExecutorInfo(t *testing.T) executorInfo {
return info return info
} }
func checkExecutor(t *testing.T, info executorInfo, assignedIdx uint64) { func checkExecutor(t e2eutils.TestingBase, info executorInfo, assignedIdx uint64) {
if !info.splitInUse { if !info.splitInUse {
t.Logf("Test splitting not in use.") t.Logf("Test splitting not in use.")
return return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment