Skip to content

Commit

Permalink
fix and detect Leaf Cache flaky tests on EVM (#485)
Browse files Browse the repository at this point in the history
* use hex values while printing the leaves in the logs

* update the types for the leaf cache response

* compare strings instead of bytes to reproduce the bug

* optmize the CI even more

* make the test retries 3 times just in case

* make the test predectable

* improve the lints and use the cache

* optmize the ci

* optmize the ci and update names

* fixing group names

* make group unique

* run integration tests on gnu linux instead of musl

* add cache to linux unit testings
  • Loading branch information
shekohex authored Apr 28, 2023
1 parent 78e6b46 commit df3b4c3
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 120 deletions.
112 changes: 40 additions & 72 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,100 +12,84 @@ env:
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}

jobs:

macos-check:
name: macOS Check
runs-on: macos-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-macos-latest-${{ matrix.target }}
cancel-in-progress: true
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}

- uses: actions/checkout@v3
with:
fetch-depth: 50

- name: Setup | Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}

- name: Setup DVC
uses: iterative/setup-dvc@v1

- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "rust"
cache-directories: ".dvc/tmp\n.dvc/cache"

- name: Build target
- name: Build Checking on ${{ matrix.target }}
run: cargo check --target=${{ matrix.target }} --features native-tls/vendored --locked

strategy:
fail-fast: true
matrix:
channel: [stable]
target:
- x86_64-apple-darwin

macos-unit-tests:
name: macOS Unit Tests
runs-on: macos-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-macos-unit-tests-${{ matrix.target }}
cancel-in-progress: true
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}

- uses: actions/checkout@v3
with:
fetch-depth: 50

- name: Setup | Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}

- name: Setup DVC
uses: iterative/setup-dvc@v1

- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "rust"
cache-directories: ".dvc/tmp\n.dvc/cache"

- name: Check target
- name: Testing on ${{ matrix.target }}
run: cargo test --target=${{ matrix.target }} --locked

strategy:
fail-fast: true
matrix:
channel: [stable]
target:
- x86_64-apple-darwin


linux-check:
name: Linux Check
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-linux-check-${{ matrix.target }}
cancel-in-progress: true
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}

- name: install system build dependencies
run: sudo apt-get update && sudo apt-get install ${DEV_PACKAGES}

- uses: actions/checkout@v3
with:
fetch-depth: 50

- name: Setup DVC
uses: iterative/setup-dvc@v1

- name: Setup | Rust
uses: dtolnay/rust-toolchain@stable
with:
Expand All @@ -114,79 +98,64 @@ jobs:

- name: Install cross
run: cargo install cross --locked
- name: Check target using cross

- name: Build Checking on ${{ matrix.target }} using cross
run: cross check --target=${{ matrix.target }} --features native-tls/vendored --locked

strategy:
fail-fast: true
matrix:
channel: [stable]
target:
- aarch64-unknown-linux-musl
- x86_64-unknown-linux-musl

linux-unit-tests:
name: Linux Unit Tests
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-linux-unit-tests-${{ matrix.target }}
cancel-in-progress: true
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}

- name: install system build dependencies
run: sudo apt-get update && sudo apt-get install ${DEV_PACKAGES}

- uses: actions/checkout@v3
with:
fetch-depth: 50

- name: Setup DVC
uses: iterative/setup-dvc@v1

- name: Setup | Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}

- name: Use Node.js
uses: actions/setup-node@v3
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
node-version-file: "./tests/.nvmrc"
cache: "yarn"
cache-dependency-path: "./tests/yarn.lock"
registry-url: "https://npm.pkg.github.com"
shared-key: "rust"
cache-directories: ".dvc/tmp\n.dvc/cache"

- run: yarn global add @webb-tools/dkg-standalone-binary@latest
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Env file
run: |
touch .env
echo ETH1_INFURA_API_KEY = ${{ secrets.ETH1_INFURA_API_KEY }} >> .env
- name: Install cross
run: cargo install cross --locked
- name: Build target using cross
run: cross test --target=${{ matrix.target }} --features native-tls/vendored --locked
touch .env
echo ETH1_INFURA_API_KEY = ${{ secrets.ETH1_INFURA_API_KEY }} >> .env
- name: Testing on ${{ matrix.target }}
run: cargo test --target=${{ matrix.target }} --features native-tls/vendored --locked

strategy:
fail-fast: true
matrix:
channel: [stable]
target:
- aarch64-unknown-linux-musl
- x86_64-unknown-linux-musl

- x86_64-unknown-linux-gnu

linux-integration-tests:
name: Linux Integration Tests
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-linux-integration-tests-${{ matrix.target }}-${{ matrix.test-type }}
cancel-in-progress: true
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}

- name: install system build dependencies
run: sudo apt-get update && sudo apt-get install ${DEV_PACKAGES}

Expand All @@ -211,21 +180,20 @@ jobs:
cache-dependency-path: "./tests/yarn.lock"
registry-url: "https://npm.pkg.github.com"

- name: Install NPM Packages.
- name: Install Node Packages.
run: cd tests && dvc pull && yarn

- name: Pull Docker Images used for testing.
run: docker pull ghcr.io/webb-tools/protocol-substrate-standalone-node:stable

- name: Webb Relayer Integration tests.
run: cd tests && yarn ${{ matrix.test-type }}

strategy:
fail-fast: false
matrix:
channel: [stable]
target:
- x86_64-unknown-linux-musl
- x86_64-unknown-linux-gnu
test-type:
- test-evm
- test-substrate
36 changes: 15 additions & 21 deletions .github/workflows/lints.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
on:
push:
pull_request:
branches:
- develop
Expand All @@ -11,27 +10,24 @@ env:

jobs:
clippy:
name: Rust Clippy
name: Clippy
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-clippy
cancel-in-progress: true
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}
- name: install system build dependencies
run: sudo apt-get update && sudo apt-get install ${DEV_PACKAGES}

- name: Checkout sources
uses: actions/checkout@v2
- name: Cache Cargo
uses: actions/cache@v2

- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
target
target/debug
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
shared-key: "rust"
cache-directories: ".dvc/tmp\n.dvc/cache"

- name: Install stable toolchain with clippy available
uses: dtolnay/rust-toolchain@stable
with:
Expand All @@ -42,14 +38,12 @@ jobs:
continue-on-error: false

rustfmt:
name: Rust Format
name: Format
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-rustfmt
cancel-in-progress: true
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}

- name: Checkout sources
uses: actions/checkout@v2

Expand Down
2 changes: 1 addition & 1 deletion event-watchers/evm/src/vanchor/vanchor_leaves_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl EventHandler for VAnchorLeavesHandler {
tracing::Level::DEBUG,
kind = %webb_relayer_utils::probe::Kind::LeavesStore,
leaf_index = %value.0,
leaf = %format!("{:?}", value.1),
leaf = %hex::encode(value.1),
chain_id = %chain_id,
block_number = %log.block_number
);
Expand Down
1 change: 0 additions & 1 deletion tests/.mocharc.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"ignore": ["node_modules/**"],
"slow": 90000,
"timeout": 600000,
"retries": 0,
// jobs (how many tests run in parallel)
// for now it is 1, since running many nodes at the same time causes
// the tests to fail.
Expand Down
6 changes: 3 additions & 3 deletions tests/lib/webbRelayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import {
IVariableAnchorExtData,
IVariableAnchorPublicInputs,
} from '@webb-tools/interfaces';
import { ChildProcess, spawn, execSync } from 'child_process';
import { ChildProcess, spawn } from 'child_process';
import { EventEmitter } from 'events';
import JSONStream from 'JSONStream';
import { BigNumber, BigNumberish } from 'ethers';
import { BigNumber } from 'ethers';
import { ConvertToKebabCase } from './tsHacks';
import { padHexString } from '../lib/utils.js';

Expand Down Expand Up @@ -633,7 +633,7 @@ export interface WebbRelayerInfo {
}

export interface LeavesCacheResponse {
leaves: [string];
leaves: number[][];
lastQueriedBlock: string;
}

Expand Down
Loading

0 comments on commit df3b4c3

Please sign in to comment.