From 4a438c23cb74f87fb24c96d56c8a4678f16c452d Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Wed, 17 Aug 2022 10:40:52 +0200 Subject: [PATCH 01/31] update github workflow to upload coverage reports --- .github/workflows/rust.yml | 40 +++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index e0865ad9e..452351800 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -33,11 +33,28 @@ jobs: default: true override: true profile: minimal - components: rustfmt, clippy + components: rustfmt, clippy, llvm-tools-preview + + - name: Download grcov + run: | + mkdir -p "${HOME}/.local/bin" + curl -sL https://github.com/mozilla/grcov/releases/download/v0.8.11/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - -C "${HOME}/.local/bin" + echo "$HOME/.local/bin" >> $GITHUB_PATH + + - name: Run xtask coverage + uses: actions-rs/cargo@v1 + with: + command: xtask + args: coverage + + - name: Upload to codecov.io + uses: codecov/codecov-action@v3 + with: + files: coverage/*.lcov - name: Cache Dependencies uses: Swatinem/rust-cache@v1 - + - name: Tests run: ./scripts/tests/${{ matrix.scripts }}.sh @@ -56,11 +73,28 @@ jobs: default: true override: true profile: minimal - components: rustfmt, clippy + components: rustfmt, clippy, llvm-tools-preview - uses: actions-rs/install@v0.1 with: crate: cargo-fuzz use-tool-cache: true + - name: Download grcov + run: | + mkdir -p "${HOME}/.local/bin" + curl -sL https://github.com/mozilla/grcov/releases/download/v0.8.11/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - -C "${HOME}/.local/bin" + echo "$HOME/.local/bin" >> $GITHUB_PATH + + - name: Run xtask coverage + uses: actions-rs/cargo@v1 + with: + command: xtask + args: coverage + + - name: Upload to codecov.io + uses: codecov/codecov-action@v3 + with: + files: coverage/*.lcov + - run: ./scripts/tests/fuzz.sh From 423cc450d4bde6b38ff6e9e3d2638cd1820ccfdd Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Wed, 17 Aug 2022 11:25:37 +0200 Subject: [PATCH 02/31] avoid using xtask --- .github/workflows/rust.yml | 38 ++++++++++++---------------------- scripts/tests/aux-functions.sh | 2 +- scripts/tests/misc.sh | 4 +++- 3 files changed, 17 insertions(+), 27 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 452351800..911235d37 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -35,28 +35,22 @@ jobs: profile: minimal components: rustfmt, clippy, llvm-tools-preview + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + - name: Download grcov run: | mkdir -p "${HOME}/.local/bin" curl -sL https://github.com/mozilla/grcov/releases/download/v0.8.11/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - -C "${HOME}/.local/bin" echo "$HOME/.local/bin" >> $GITHUB_PATH - - - name: Run xtask coverage - uses: actions-rs/cargo@v1 - with: - command: xtask - args: coverage + + - name: Tests + run: ./scripts/tests/${{ matrix.scripts }}.sh - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: coverage/*.lcov - - - name: Cache Dependencies - uses: Swatinem/rust-cache@v1 - - - name: Tests - run: ./scripts/tests/${{ matrix.scripts }}.sh + files: ./misc/*.lcov fuzz: name: Fuzz @@ -75,26 +69,20 @@ jobs: profile: minimal components: rustfmt, clippy, llvm-tools-preview - - uses: actions-rs/install@v0.1 - with: - crate: cargo-fuzz - use-tool-cache: true - - name: Download grcov run: | mkdir -p "${HOME}/.local/bin" curl -sL https://github.com/mozilla/grcov/releases/download/v0.8.11/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - -C "${HOME}/.local/bin" echo "$HOME/.local/bin" >> $GITHUB_PATH - - name: Run xtask coverage - uses: actions-rs/cargo@v1 + - uses: actions-rs/install@v0.1 with: - command: xtask - args: coverage + crate: cargo-fuzz + use-tool-cache: true + + - run: ./scripts/tests/fuzz.sh - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: coverage/*.lcov - - - run: ./scripts/tests/fuzz.sh + files: ./misc/*.lcov diff --git a/scripts/tests/aux-functions.sh b/scripts/tests/aux-functions.sh index e0d0848ad..4afde9c42 100755 --- a/scripts/tests/aux-functions.sh +++ b/scripts/tests/aux-functions.sh @@ -15,5 +15,5 @@ test_package_with_feature() { local features=$2 /bin/echo -e "\e[0;33m***** Testing '$package' with features '$features' *****\e[0m\n" - cargo test --features $features --manifest-path $package/Cargo.toml --no-default-features --release + CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw' cargo test --features $features --manifest-path $package/Cargo.toml --no-default-features --release } diff --git a/scripts/tests/misc.sh b/scripts/tests/misc.sh index 38abf6e13..ffde9f91b 100755 --- a/scripts/tests/misc.sh +++ b/scripts/tests/misc.sh @@ -24,4 +24,6 @@ do test_package_with_feature "$package" std,runtime-benchmarks echo "TEST $package std,runtime-benchmarks" fi -done \ No newline at end of file +done + +grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o misc/tests.lcov From 8195c5e8b185393ef28bbe25e4cf9ceb5c2a2046 Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Wed, 17 Aug 2022 13:22:16 +0200 Subject: [PATCH 03/31] use relative path for codecov CI workflow --- .github/workflows/rust.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 911235d37..15c0c65f4 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -50,7 +50,7 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: ./misc/*.lcov + files: /misc/*.lcov fuzz: name: Fuzz @@ -85,4 +85,4 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: ./misc/*.lcov + files: /misc/*.lcov From 334b510ed42538f8b34d566c4f7998888e0f67b3 Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Wed, 17 Aug 2022 13:32:41 +0200 Subject: [PATCH 04/31] improve relative paths --- .github/workflows/rust.yml | 4 ++-- scripts/tests/misc.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 15c0c65f4..c30f55878 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -50,7 +50,7 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: /misc/*.lcov + files: ../../misc/*.lcov fuzz: name: Fuzz @@ -85,4 +85,4 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: /misc/*.lcov + files: ../../misc/*.lcov diff --git a/scripts/tests/misc.sh b/scripts/tests/misc.sh index ffde9f91b..712374413 100755 --- a/scripts/tests/misc.sh +++ b/scripts/tests/misc.sh @@ -26,4 +26,4 @@ do fi done -grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o misc/tests.lcov +grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o ../../misc/tests.lcov From 7bc87b63e757acc501ee59b87f6fb3c1d1796f46 Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Wed, 17 Aug 2022 13:46:16 +0200 Subject: [PATCH 05/31] update relative paths --- .github/workflows/rust.yml | 4 ++-- scripts/tests/misc.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c30f55878..911235d37 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -50,7 +50,7 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: ../../misc/*.lcov + files: ./misc/*.lcov fuzz: name: Fuzz @@ -85,4 +85,4 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: ../../misc/*.lcov + files: ./misc/*.lcov diff --git a/scripts/tests/misc.sh b/scripts/tests/misc.sh index 712374413..ffde9f91b 100755 --- a/scripts/tests/misc.sh +++ b/scripts/tests/misc.sh @@ -26,4 +26,4 @@ do fi done -grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o ../../misc/tests.lcov +grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o misc/tests.lcov From a114cdf39b1618244bb5dd77a952ef5221a14daa Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Wed, 17 Aug 2022 14:00:41 +0200 Subject: [PATCH 06/31] update path --- .github/workflows/rust.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 911235d37..0ee4c1ad9 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -50,7 +50,7 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: ./misc/*.lcov + files: /misc/tests.lcov fuzz: name: Fuzz @@ -85,4 +85,4 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: ./misc/*.lcov + files: /misc/fuzz.lcov From 2c6c66a206eeba7b4cc987f19eb6077d21a51a2c Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Wed, 17 Aug 2022 14:20:51 +0200 Subject: [PATCH 07/31] use coverage for fuzz --- .github/workflows/rust.yml | 4 ++-- scripts/tests/fuzz.sh | 48 ++++++++++++++++++++------------------ 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 0ee4c1ad9..15c0c65f4 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -50,7 +50,7 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: /misc/tests.lcov + files: /misc/*.lcov fuzz: name: Fuzz @@ -85,4 +85,4 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: /misc/fuzz.lcov + files: /misc/*.lcov diff --git a/scripts/tests/fuzz.sh b/scripts/tests/fuzz.sh index 2fb08c5e9..86b13e2f0 100755 --- a/scripts/tests/fuzz.sh +++ b/scripts/tests/fuzz.sh @@ -33,35 +33,37 @@ RIKIDDO_WITH_CALCULATED_FEE_FACT=1750 RIKIDDO_PALLET_FACT=1000 # --- Prediction Market Pallet fuzz tests --- -RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/prediction-markets/fuzz pm_full_workflow -- -runs=$RUNS +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/prediction-markets/fuzz pm_full_workflow -- -runs=$RUNS # --- Swaps Pallet fuzz tests --- -RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz create_pool -- -runs=$(($(($RUNS * $CREATE_POOL_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_join -- -runs=$(($(($RUNS * $POOL_JOIN_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz swap_exact_amount_in -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_IN_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz swap_exact_amount_out -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_OUT_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_exit -- -runs=$(($(($RUNS * $POOL_EXIT_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz create_pool -- -runs=$(($(($RUNS * $CREATE_POOL_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_join -- -runs=$(($(($RUNS * $POOL_JOIN_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz swap_exact_amount_in -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_IN_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz swap_exact_amount_out -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_OUT_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_exit -- -runs=$(($(($RUNS * $POOL_EXIT_FACT)) / $BASE)) # --- Orderbook-v1 Pallet fuzz tests --- -RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/orderbook-v1/fuzz orderbook_v1_full_workflow -- -runs=$RUNS +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/orderbook-v1/fuzz orderbook_v1_full_workflow -- -runs=$RUNS # --- Rikiddo Pallet fuzz tests --- # Release is required here since it triggers debug assertions otherwise # Using the default RUNS multiplier, each fuzz test needs approx. 6-7 seconds -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fee_sigmoid -- -runs=$(($(($RUNS * $FEE_SIGMOID_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fixedi_to_fixedu_conversion -- -runs=$(($(($RUNS * $FIXEDI_TO_FIXEDU_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fixedu_to_fixedi_conversion -- -runs=$(($(($RUNS * $FIXEDU_TO_FIXEDI_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz balance_to_fixedu_conversion -- -runs=$(($(($RUNS * $BALANCE_TO_FIXEDU_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fixedu_to_balance_conversion -- -runs=$(($(($RUNS * $FIXEDU_TO_BALANCE_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_first_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_FIRST_STATE_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_second_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_SECOND_STATE_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_third_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_THIRD_STATE_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_estimate_ema -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_ESTIMATE_EMA_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_initial_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_INITIAL_FEE_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_calculated_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_CALCULATED_FEE_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fee_sigmoid -- -runs=$(($(($RUNS * $FEE_SIGMOID_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fixedi_to_fixedu_conversion -- -runs=$(($(($RUNS * $FIXEDI_TO_FIXEDU_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fixedu_to_fixedi_conversion -- -runs=$(($(($RUNS * $FIXEDU_TO_FIXEDI_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz balance_to_fixedu_conversion -- -runs=$(($(($RUNS * $BALANCE_TO_FIXEDU_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fixedu_to_balance_conversion -- -runs=$(($(($RUNS * $FIXEDU_TO_BALANCE_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_first_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_FIRST_STATE_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_second_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_SECOND_STATE_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_third_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_THIRD_STATE_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_estimate_ema -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_ESTIMATE_EMA_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_initial_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_INITIAL_FEE_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_calculated_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_CALCULATED_FEE_FACT)) / $BASE)) # This actually needs approx. 107 seconds. Need to find a way to optimize fuzzing on-chain -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_pallet -- -runs=$(($(($RUNS * $RIKIDDO_PALLET_FACT)) / $BASE)) \ No newline at end of file +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_pallet -- -runs=$(($(($RUNS * $RIKIDDO_PALLET_FACT)) / $BASE)) + +grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o misc/fuzz.lcov From eb797dda0011e7c79e5eae95b26b8143f988de15 Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Wed, 17 Aug 2022 14:22:12 +0200 Subject: [PATCH 08/31] update lcov path --- .github/workflows/rust.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 15c0c65f4..0ee4c1ad9 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -50,7 +50,7 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: /misc/*.lcov + files: /misc/tests.lcov fuzz: name: Fuzz @@ -85,4 +85,4 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: /misc/*.lcov + files: /misc/fuzz.lcov From 7a1df508bfd787d160da041166440fbf87c98c01 Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Wed, 17 Aug 2022 21:45:59 +0200 Subject: [PATCH 09/31] use release flag for fuzz tests and grcov --- .github/workflows/rust.yml | 3 +++ scripts/tests/fuzz.sh | 24 ++++++++++++------------ scripts/tests/misc.sh | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 0ee4c1ad9..716514dc6 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -68,6 +68,9 @@ jobs: override: true profile: minimal components: rustfmt, clippy, llvm-tools-preview + + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 - name: Download grcov run: | diff --git a/scripts/tests/fuzz.sh b/scripts/tests/fuzz.sh index 86b13e2f0..8d9f1cb18 100755 --- a/scripts/tests/fuzz.sh +++ b/scripts/tests/fuzz.sh @@ -33,21 +33,21 @@ RIKIDDO_WITH_CALCULATED_FEE_FACT=1750 RIKIDDO_PALLET_FACT=1000 # --- Prediction Market Pallet fuzz tests --- -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/prediction-markets/fuzz pm_full_workflow -- -runs=$RUNS +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/prediction-markets/fuzz pm_full_workflow -- -runs=$RUNS # --- Swaps Pallet fuzz tests --- -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz create_pool -- -runs=$(($(($RUNS * $CREATE_POOL_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_join -- -runs=$(($(($RUNS * $POOL_JOIN_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz swap_exact_amount_in -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_IN_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz swap_exact_amount_out -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_OUT_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_exit -- -runs=$(($(($RUNS * $POOL_EXIT_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz create_pool -- -runs=$(($(($RUNS * $CREATE_POOL_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_join -- -runs=$(($(($RUNS * $POOL_JOIN_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz swap_exact_amount_in -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_IN_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz swap_exact_amount_out -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_OUT_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_exit -- -runs=$(($(($RUNS * $POOL_EXIT_FACT)) / $BASE)) # --- Orderbook-v1 Pallet fuzz tests --- -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --fuzz-dir zrml/orderbook-v1/fuzz orderbook_v1_full_workflow -- -runs=$RUNS +CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/orderbook-v1/fuzz orderbook_v1_full_workflow -- -runs=$RUNS # --- Rikiddo Pallet fuzz tests --- # Release is required here since it triggers debug assertions otherwise @@ -66,4 +66,4 @@ CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-f # This actually needs approx. 107 seconds. Need to find a way to optimize fuzzing on-chain CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_pallet -- -runs=$(($(($RUNS * $RIKIDDO_PALLET_FACT)) / $BASE)) -grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o misc/fuzz.lcov +grcov . --binary-path ./target/release/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o misc/fuzz.lcov diff --git a/scripts/tests/misc.sh b/scripts/tests/misc.sh index ffde9f91b..b204cca33 100755 --- a/scripts/tests/misc.sh +++ b/scripts/tests/misc.sh @@ -26,4 +26,4 @@ do fi done -grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o misc/tests.lcov +grcov . --binary-path ./target/release/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o misc/tests.lcov From 1d40e59c2db103edc87b8a32edcb0d0ccd2c0cba Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Mon, 12 Sep 2022 12:58:09 +0200 Subject: [PATCH 10/31] use grcov github action --- .github/workflows/rust.yml | 22 ++++++++-------------- scripts/tests/fuzz.sh | 2 -- scripts/tests/misc.sh | 2 -- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 716514dc6..69393523d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -38,19 +38,16 @@ jobs: - name: Cache Dependencies uses: Swatinem/rust-cache@v1 - - name: Download grcov - run: | - mkdir -p "${HOME}/.local/bin" - curl -sL https://github.com/mozilla/grcov/releases/download/v0.8.11/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - -C "${HOME}/.local/bin" - echo "$HOME/.local/bin" >> $GITHUB_PATH - - name: Tests run: ./scripts/tests/${{ matrix.scripts }}.sh + - id: coverage + uses: actions-rs/grcov@v0.1 + - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: /misc/tests.lcov + files: ${{ steps.coverage.outputs.report }} fuzz: name: Fuzz @@ -71,12 +68,6 @@ jobs: - name: Cache Dependencies uses: Swatinem/rust-cache@v1 - - - name: Download grcov - run: | - mkdir -p "${HOME}/.local/bin" - curl -sL https://github.com/mozilla/grcov/releases/download/v0.8.11/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - -C "${HOME}/.local/bin" - echo "$HOME/.local/bin" >> $GITHUB_PATH - uses: actions-rs/install@v0.1 with: @@ -85,7 +76,10 @@ jobs: - run: ./scripts/tests/fuzz.sh + - id: coverage + uses: actions-rs/grcov@v0.1 + - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: /misc/fuzz.lcov + files: ${{ steps.coverage.outputs.report }} diff --git a/scripts/tests/fuzz.sh b/scripts/tests/fuzz.sh index 8d9f1cb18..79e20efca 100755 --- a/scripts/tests/fuzz.sh +++ b/scripts/tests/fuzz.sh @@ -65,5 +65,3 @@ CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-f CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_calculated_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_CALCULATED_FEE_FACT)) / $BASE)) # This actually needs approx. 107 seconds. Need to find a way to optimize fuzzing on-chain CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_pallet -- -runs=$(($(($RUNS * $RIKIDDO_PALLET_FACT)) / $BASE)) - -grcov . --binary-path ./target/release/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o misc/fuzz.lcov diff --git a/scripts/tests/misc.sh b/scripts/tests/misc.sh index b204cca33..1b7d9ae05 100755 --- a/scripts/tests/misc.sh +++ b/scripts/tests/misc.sh @@ -25,5 +25,3 @@ do echo "TEST $package std,runtime-benchmarks" fi done - -grcov . --binary-path ./target/release/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o misc/tests.lcov From 90b452d059ed92ea8531b594cc911def926e3d82 Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Mon, 12 Sep 2022 14:10:38 +0200 Subject: [PATCH 11/31] use grcov config --- .github/workflows/rust.yml | 4 ++++ misc/grcov.yml | 11 +++++++++++ 2 files changed, 15 insertions(+) create mode 100644 misc/grcov.yml diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index b854828c6..4dda2f1c0 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -67,6 +67,8 @@ jobs: - id: coverage uses: actions-rs/grcov@v0.1 + with: + config: ./misc/grcov.yml - name: Upload to codecov.io uses: codecov/codecov-action@v3 @@ -102,6 +104,8 @@ jobs: - id: coverage uses: actions-rs/grcov@v0.1 + with: + config: ./misc/grcov.yml - name: Upload to codecov.io uses: codecov/codecov-action@v3 diff --git a/misc/grcov.yml b/misc/grcov.yml new file mode 100644 index 000000000..880aaa217 --- /dev/null +++ b/misc/grcov.yml @@ -0,0 +1,11 @@ +branch: true +ignore-not-existing: true +llvm: true +filter: covered +source-dir: . +output-type: lcov +output-path: ./tmp/lcov.info +binary-path: ./target/release/deps/ +ignore: + - "/*" + - "../*" \ No newline at end of file From 13269b5525772c0d494eca5b8a1bee98df6472e8 Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Mon, 12 Sep 2022 14:46:44 +0200 Subject: [PATCH 12/31] use grcov github action test suggestion --- {misc => .github/actions-rs}/grcov.yml | 0 .github/workflows/rust.yml | 4 ---- scripts/tests/aux-functions.sh | 2 +- 3 files changed, 1 insertion(+), 5 deletions(-) rename {misc => .github/actions-rs}/grcov.yml (100%) diff --git a/misc/grcov.yml b/.github/actions-rs/grcov.yml similarity index 100% rename from misc/grcov.yml rename to .github/actions-rs/grcov.yml diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 4dda2f1c0..b854828c6 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -67,8 +67,6 @@ jobs: - id: coverage uses: actions-rs/grcov@v0.1 - with: - config: ./misc/grcov.yml - name: Upload to codecov.io uses: codecov/codecov-action@v3 @@ -104,8 +102,6 @@ jobs: - id: coverage uses: actions-rs/grcov@v0.1 - with: - config: ./misc/grcov.yml - name: Upload to codecov.io uses: codecov/codecov-action@v3 diff --git a/scripts/tests/aux-functions.sh b/scripts/tests/aux-functions.sh index 4afde9c42..f9b54e4d0 100755 --- a/scripts/tests/aux-functions.sh +++ b/scripts/tests/aux-functions.sh @@ -15,5 +15,5 @@ test_package_with_feature() { local features=$2 /bin/echo -e "\e[0;33m***** Testing '$package' with features '$features' *****\e[0m\n" - CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw' cargo test --features $features --manifest-path $package/Cargo.toml --no-default-features --release + CARGO_INCREMENTAL=0 RUSTFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' RUSTDOCFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' cargo test --features $features --manifest-path $package/Cargo.toml --no-default-features --release } From f57c2e0f69c9a5e472ebed4a15a9f939150c0cf4 Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Mon, 12 Sep 2022 15:54:29 +0200 Subject: [PATCH 13/31] revert to source based code coverage --- .github/actions-rs/grcov.yml | 11 ----------- .github/workflows/rust.yml | 20 ++++++++++++-------- scripts/tests/aux-functions.sh | 2 +- scripts/tests/fuzz.sh | 2 ++ scripts/tests/misc.sh | 2 ++ 5 files changed, 17 insertions(+), 20 deletions(-) delete mode 100644 .github/actions-rs/grcov.yml diff --git a/.github/actions-rs/grcov.yml b/.github/actions-rs/grcov.yml deleted file mode 100644 index 880aaa217..000000000 --- a/.github/actions-rs/grcov.yml +++ /dev/null @@ -1,11 +0,0 @@ -branch: true -ignore-not-existing: true -llvm: true -filter: covered -source-dir: . -output-type: lcov -output-path: ./tmp/lcov.info -binary-path: ./target/release/deps/ -ignore: - - "/*" - - "../*" \ No newline at end of file diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index b854828c6..5cd9e865d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -62,16 +62,18 @@ jobs: - name: Cache Dependencies uses: Swatinem/rust-cache@v1 + - uses: actions-rs/install@v0.1 + with: + crate: grcov + use-tool-cache: true + - name: Tests run: ./scripts/tests/${{ matrix.scripts }}.sh - - id: coverage - uses: actions-rs/grcov@v0.1 - - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: ${{ steps.coverage.outputs.report }} + files: ./tmp/*.lcov fuzz: name: Fuzz @@ -92,6 +94,11 @@ jobs: - name: Cache Dependencies uses: Swatinem/rust-cache@v1 + + - uses: actions-rs/install@v0.1 + with: + crate: grcov + use-tool-cache: true - uses: actions-rs/install@v0.1 with: @@ -100,10 +107,7 @@ jobs: - run: ./scripts/tests/fuzz.sh - - id: coverage - uses: actions-rs/grcov@v0.1 - - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: ${{ steps.coverage.outputs.report }} + files: ./tmp/*.lcov diff --git a/scripts/tests/aux-functions.sh b/scripts/tests/aux-functions.sh index f9b54e4d0..7e3752135 100755 --- a/scripts/tests/aux-functions.sh +++ b/scripts/tests/aux-functions.sh @@ -15,5 +15,5 @@ test_package_with_feature() { local features=$2 /bin/echo -e "\e[0;33m***** Testing '$package' with features '$features' *****\e[0m\n" - CARGO_INCREMENTAL=0 RUSTFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' RUSTDOCFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' cargo test --features $features --manifest-path $package/Cargo.toml --no-default-features --release + CARGO_INCREMENTAL=0 RUSTFLAGS="-Cinstrument-coverage" LLVM_PROFILE_FILE="cargo-test-%p-%m.profraw" cargo test --features $features --manifest-path $package/Cargo.toml --no-default-features --release } diff --git a/scripts/tests/fuzz.sh b/scripts/tests/fuzz.sh index 79e20efca..a0f99919a 100755 --- a/scripts/tests/fuzz.sh +++ b/scripts/tests/fuzz.sh @@ -65,3 +65,5 @@ CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-f CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_calculated_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_CALCULATED_FEE_FACT)) / $BASE)) # This actually needs approx. 107 seconds. Need to find a way to optimize fuzzing on-chain CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_pallet -- -runs=$(($(($RUNS * $RIKIDDO_PALLET_FACT)) / $BASE)) + +grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o misc/fuzz.lcov \ No newline at end of file diff --git a/scripts/tests/misc.sh b/scripts/tests/misc.sh index 567b380aa..0826a16df 100755 --- a/scripts/tests/misc.sh +++ b/scripts/tests/misc.sh @@ -23,3 +23,5 @@ do echo "TEST $package std,runtime-benchmarks" fi done + +grcov . --binary-path ./target/release/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o tmp/tests.lcov \ No newline at end of file From eb06f3518ad20aecf7150f32c76b6bb2b8d17435 Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Mon, 12 Sep 2022 16:28:16 +0200 Subject: [PATCH 14/31] create tmp directory --- scripts/tests/fuzz.sh | 3 ++- scripts/tests/misc.sh | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/tests/fuzz.sh b/scripts/tests/fuzz.sh index a0f99919a..bb385bb09 100755 --- a/scripts/tests/fuzz.sh +++ b/scripts/tests/fuzz.sh @@ -66,4 +66,5 @@ CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-f # This actually needs approx. 107 seconds. Need to find a way to optimize fuzzing on-chain CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_pallet -- -runs=$(($(($RUNS * $RIKIDDO_PALLET_FACT)) / $BASE)) -grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o misc/fuzz.lcov \ No newline at end of file +mkdir tmp +grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o tmp/fuzz.lcov \ No newline at end of file diff --git a/scripts/tests/misc.sh b/scripts/tests/misc.sh index 0826a16df..c3478c27f 100755 --- a/scripts/tests/misc.sh +++ b/scripts/tests/misc.sh @@ -24,4 +24,5 @@ do fi done +mkdir tmp grcov . --binary-path ./target/release/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o tmp/tests.lcov \ No newline at end of file From 511a7e238ce4e32d02405eb17ab1c9ab7524e11f Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Tue, 13 Sep 2022 06:36:33 +0200 Subject: [PATCH 15/31] use release for fuzz grcov --- scripts/tests/fuzz.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/tests/fuzz.sh b/scripts/tests/fuzz.sh index bb385bb09..4dbbc946a 100755 --- a/scripts/tests/fuzz.sh +++ b/scripts/tests/fuzz.sh @@ -67,4 +67,4 @@ CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-f CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_pallet -- -runs=$(($(($RUNS * $RIKIDDO_PALLET_FACT)) / $BASE)) mkdir tmp -grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o tmp/fuzz.lcov \ No newline at end of file +grcov . --binary-path ./target/release/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o tmp/fuzz.lcov \ No newline at end of file From 91526c937382eda7728874ed59be9d07e222a5e9 Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Tue, 13 Sep 2022 06:41:13 +0200 Subject: [PATCH 16/31] update codecov lcov file path --- .github/workflows/rust.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 5cd9e865d..adca3ecfb 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -73,7 +73,7 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: ./tmp/*.lcov + files: /tmp/tests.lcov fuzz: name: Fuzz @@ -110,4 +110,4 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: ./tmp/*.lcov + files: /tmp/fuzz.lcov From c9bc160fd50eb769aa4218ee9f4907ad0a111991 Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Tue, 13 Sep 2022 11:17:30 +0200 Subject: [PATCH 17/31] use tmp runner folder for coverage data --- .github/workflows/rust.yml | 4 ++-- scripts/tests/fuzz.sh | 3 +-- scripts/tests/misc.sh | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index adca3ecfb..735bc92ed 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -73,7 +73,7 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: /tmp/tests.lcov + files: $RUNNER_TEMP/zeitgeist-test-coverage.lcov fuzz: name: Fuzz @@ -110,4 +110,4 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: /tmp/fuzz.lcov + files: $RUNNER_TEMP/zeitgeist-fuzz-coverage.lcov diff --git a/scripts/tests/fuzz.sh b/scripts/tests/fuzz.sh index 4dbbc946a..febb129ce 100755 --- a/scripts/tests/fuzz.sh +++ b/scripts/tests/fuzz.sh @@ -66,5 +66,4 @@ CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-f # This actually needs approx. 107 seconds. Need to find a way to optimize fuzzing on-chain CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_pallet -- -runs=$(($(($RUNS * $RIKIDDO_PALLET_FACT)) / $BASE)) -mkdir tmp -grcov . --binary-path ./target/release/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o tmp/fuzz.lcov \ No newline at end of file +grcov . --binary-path ./target/release/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o $RUNNER_TEMP/zeitgeist-fuzz-coverage.lcov diff --git a/scripts/tests/misc.sh b/scripts/tests/misc.sh index c3478c27f..7362ca7b2 100755 --- a/scripts/tests/misc.sh +++ b/scripts/tests/misc.sh @@ -24,5 +24,4 @@ do fi done -mkdir tmp -grcov . --binary-path ./target/release/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o tmp/tests.lcov \ No newline at end of file +grcov . --binary-path ./target/release/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o $RUNNER_TEMP/zeitgeist-test-coverage.lcov From 7e6ac549d8b511e04618a7bdac1a01bd16deaf2f Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Tue, 13 Sep 2022 11:31:07 +0200 Subject: [PATCH 18/31] correct runner path in gh actions --- .github/workflows/rust.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 735bc92ed..645c2b9c6 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -73,7 +73,7 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: $RUNNER_TEMP/zeitgeist-test-coverage.lcov + files: ${{ RUNNER_TEMP }}/zeitgeist-test-coverage.lcov fuzz: name: Fuzz @@ -110,4 +110,4 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: $RUNNER_TEMP/zeitgeist-fuzz-coverage.lcov + files: ${{ RUNNER_TEMP }}/zeitgeist-fuzz-coverage.lcov From a918dfaa1f8dec9cd82e3aff1267c6cdecdac2a0 Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Tue, 13 Sep 2022 11:38:44 +0200 Subject: [PATCH 19/31] use github actions default env var RUNNER_TEMP --- .github/workflows/rust.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 645c2b9c6..663cdad8c 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -73,7 +73,7 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: ${{ RUNNER_TEMP }}/zeitgeist-test-coverage.lcov + files: ${{ env.RUNNER_TEMP }}/zeitgeist-test-coverage.lcov fuzz: name: Fuzz @@ -110,4 +110,4 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: ${{ RUNNER_TEMP }}/zeitgeist-fuzz-coverage.lcov + files: ${{ env.RUNNER_TEMP }}/zeitgeist-fuzz-coverage.lcov From 2db1628ca948c9f087c4a1b0073b3a30f90ea9f7 Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Tue, 13 Sep 2022 11:55:07 +0200 Subject: [PATCH 20/31] gh action tmp folder and fail_ci_if_error true --- .github/workflows/rust.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 663cdad8c..778db575b 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -73,7 +73,9 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: ${{ env.RUNNER_TEMP }}/zeitgeist-test-coverage.lcov + directory: ${{ runner.temp }} + files: ./zeitgeist-test-coverage.lcov + fail_ci_if_error: true fuzz: name: Fuzz @@ -110,4 +112,6 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: ${{ env.RUNNER_TEMP }}/zeitgeist-fuzz-coverage.lcov + directory: ${{ runner.temp }} + files: ./zeitgeist-fuzz-coverage.lcov + fail_ci_if_error: true From c1d8c5bd9eb2ee86413843aa3c55b4e789557bb9 Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Tue, 13 Sep 2022 12:07:30 +0200 Subject: [PATCH 21/31] correct file path --- .github/workflows/rust.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 778db575b..a6a12bcb6 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -73,8 +73,7 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - directory: ${{ runner.temp }} - files: ./zeitgeist-test-coverage.lcov + files: ${{ runner.temp }}/zeitgeist-test-coverage.lcov fail_ci_if_error: true fuzz: @@ -111,7 +110,6 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 - with: - directory: ${{ runner.temp }} - files: ./zeitgeist-fuzz-coverage.lcov + with: + files: ${{ runner.temp }}/zeitgeist-fuzz-coverage.lcov fail_ci_if_error: true From ed22a33d8059d2b0fa9437dd30bbf934fc71591f Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Tue, 13 Sep 2022 13:01:14 +0200 Subject: [PATCH 22/31] add own job for test and coverage upload --- .github/workflows/rust.yml | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index a6a12bcb6..ef150afcf 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -34,17 +34,40 @@ jobs: - name: Format run: ./scripts/tests/format.sh --check - tests: - name: Tests + checks: + name: Checks runs-on: ubuntu-latest strategy: matrix: scripts: [ "clippy", - "misc", "parachain", "standalone" ] + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + target: wasm32-unknown-unknown + default: true + override: true + profile: minimal + components: rustfmt, clippy + + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + + - name: Checks + run: ./scripts/tests/${{ matrix.scripts }}.sh + + tests: + needs: checks + name: Tests + runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v2 @@ -68,7 +91,7 @@ jobs: use-tool-cache: true - name: Tests - run: ./scripts/tests/${{ matrix.scripts }}.sh + run: ./scripts/tests/misc.sh - name: Upload to codecov.io uses: codecov/codecov-action@v3 From 8bd17aaa54a47b21bf7f3c1153acb8ab42968bd4 Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Tue, 13 Sep 2022 13:22:27 +0200 Subject: [PATCH 23/31] optimise github actions --- .github/workflows/rust.yml | 51 +++++++++++--------------------------- 1 file changed, 14 insertions(+), 37 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index ef150afcf..7f30396b4 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -10,8 +10,8 @@ env: CARGO_TERM_COLOR: always jobs: - format: - name: Format + init: + name: Initialisation runs-on: ubuntu-latest steps: - name: Checkout repository @@ -25,8 +25,16 @@ jobs: default: true override: true profile: minimal - components: rustfmt - + components: rustfmt, clippy, llvm-tools-preview + + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + + format: + needs: init + name: Format + runs-on: ubuntu-latest + steps: - uses: actions-rs/install@v0.1 with: crate: taplo-cli @@ -35,6 +43,7 @@ jobs: run: ./scripts/tests/format.sh --check checks: + needs: init name: Checks runs-on: ubuntu-latest strategy: @@ -45,46 +54,14 @@ jobs: "standalone" ] steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Install rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - target: wasm32-unknown-unknown - default: true - override: true - profile: minimal - components: rustfmt, clippy - - - name: Cache Dependencies - uses: Swatinem/rust-cache@v1 - - name: Checks run: ./scripts/tests/${{ matrix.scripts }}.sh tests: - needs: checks + needs: init name: Tests runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Install rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - target: wasm32-unknown-unknown - default: true - override: true - profile: minimal - components: rustfmt, clippy, llvm-tools-preview - - - name: Cache Dependencies - uses: Swatinem/rust-cache@v1 - - uses: actions-rs/install@v0.1 with: crate: grcov From d039f163e850fe3b5169894c69543d2fb5163652 Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Tue, 13 Sep 2022 13:37:17 +0200 Subject: [PATCH 24/31] change github workflow --- .github/workflows/rust.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 7f30396b4..716e70491 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -35,6 +35,9 @@ jobs: name: Format runs-on: ubuntu-latest steps: + - name: Checkout repository + uses: actions/checkout@v2 + - uses: actions-rs/install@v0.1 with: crate: taplo-cli @@ -54,6 +57,9 @@ jobs: "standalone" ] steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Checks run: ./scripts/tests/${{ matrix.scripts }}.sh @@ -62,10 +68,16 @@ jobs: name: Tests runs-on: ubuntu-latest steps: + - name: Checkout repository + uses: actions/checkout@v2 + - uses: actions-rs/install@v0.1 with: crate: grcov use-tool-cache: true + + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 - name: Tests run: ./scripts/tests/misc.sh @@ -92,9 +104,6 @@ jobs: override: true profile: minimal components: rustfmt, clippy, llvm-tools-preview - - - name: Cache Dependencies - uses: Swatinem/rust-cache@v1 - uses: actions-rs/install@v0.1 with: @@ -106,6 +115,9 @@ jobs: crate: cargo-fuzz use-tool-cache: true + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + - run: ./scripts/tests/fuzz.sh - name: Upload to codecov.io From db85aa983f5064331e902ed27a8d5123199cbb90 Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Tue, 13 Sep 2022 13:59:00 +0200 Subject: [PATCH 25/31] fix github actions workflow --- .github/workflows/rust.yml | 45 ++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 716e70491..cfc29932a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -10,8 +10,8 @@ env: CARGO_TERM_COLOR: always jobs: - init: - name: Initialisation + format: + name: Format runs-on: ubuntu-latest steps: - name: Checkout repository @@ -25,28 +25,19 @@ jobs: default: true override: true profile: minimal - components: rustfmt, clippy, llvm-tools-preview - - - name: Cache Dependencies - uses: Swatinem/rust-cache@v1 - - format: - needs: init - name: Format - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 + components: rustfmt - uses: actions-rs/install@v0.1 with: crate: taplo-cli + + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 - name: Format run: ./scripts/tests/format.sh --check checks: - needs: init name: Checks runs-on: ubuntu-latest strategy: @@ -60,17 +51,39 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 + - name: Install rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + target: wasm32-unknown-unknown + default: true + override: true + profile: minimal + components: rustfmt, clippy + + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + - name: Checks run: ./scripts/tests/${{ matrix.scripts }}.sh tests: - needs: init name: Tests runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v2 + - name: Install rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + target: wasm32-unknown-unknown + default: true + override: true + profile: minimal + components: rustfmt, clippy, llvm-tools-preview + - uses: actions-rs/install@v0.1 with: crate: grcov From f51da522bfa31b7a7aab07f456341aca1507db73 Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Tue, 13 Sep 2022 14:17:27 +0200 Subject: [PATCH 26/31] provide flag for github action codecov --- .github/workflows/rust.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index cfc29932a..4e086bb99 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -100,6 +100,9 @@ jobs: with: files: ${{ runner.temp }}/zeitgeist-test-coverage.lcov fail_ci_if_error: true + flags: tests + verbose: true + name: unit-tests fuzz: name: Fuzz @@ -138,3 +141,6 @@ jobs: with: files: ${{ runner.temp }}/zeitgeist-fuzz-coverage.lcov fail_ci_if_error: true + flags: fuzz + verbose: true + name: fuzz-tests From 6d585210a1a6484f4f2378396439bb10ea62de18 Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Mon, 26 Sep 2022 13:53:50 +0200 Subject: [PATCH 27/31] use debug profile for tests for better cov reports --- Cargo.toml | 4 +++ scripts/tests/aux-functions.sh | 3 +- scripts/tests/fuzz.sh | 50 +++++++++++++++++----------------- scripts/tests/misc.sh | 2 +- 4 files changed, 32 insertions(+), 27 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d20aa83bc..36cfb65b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,3 +48,7 @@ resolver = "2" [patch."https://github.com/purestake/moonbeam"] pallet-author-mapping = { git = "https://github.com/zeitgeistpm/moonbeam", branch = "downgrade-staking-and-mapping" } parachain-staking = { git = "https://github.com/zeitgeistpm/moonbeam", branch = "downgrade-staking-and-mapping" } + +[profile.fuzz] +inherits = "dev" +debug-assertions = false diff --git a/scripts/tests/aux-functions.sh b/scripts/tests/aux-functions.sh index 7e3752135..24eca780a 100755 --- a/scripts/tests/aux-functions.sh +++ b/scripts/tests/aux-functions.sh @@ -15,5 +15,6 @@ test_package_with_feature() { local features=$2 /bin/echo -e "\e[0;33m***** Testing '$package' with features '$features' *****\e[0m\n" - CARGO_INCREMENTAL=0 RUSTFLAGS="-Cinstrument-coverage" LLVM_PROFILE_FILE="cargo-test-%p-%m.profraw" cargo test --features $features --manifest-path $package/Cargo.toml --no-default-features --release + # default rustc profile dev is used to get better test coverage reports + CARGO_INCREMENTAL=0 RUSTFLAGS="-Cinstrument-coverage" LLVM_PROFILE_FILE="cargo-test-%p-%m.profraw" cargo test --features $features --manifest-path $package/Cargo.toml --no-default-features } diff --git a/scripts/tests/fuzz.sh b/scripts/tests/fuzz.sh index febb129ce..a50923f55 100755 --- a/scripts/tests/fuzz.sh +++ b/scripts/tests/fuzz.sh @@ -33,37 +33,37 @@ RIKIDDO_WITH_CALCULATED_FEE_FACT=1750 RIKIDDO_PALLET_FACT=1000 # --- Prediction Market Pallet fuzz tests --- -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/prediction-markets/fuzz pm_full_workflow -- -runs=$RUNS +cargo fuzz run --profile=fuzz --fuzz-dir zrml/prediction-markets/fuzz pm_full_workflow -- -runs=$RUNS # --- Swaps Pallet fuzz tests --- -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz create_pool -- -runs=$(($(($RUNS * $CREATE_POOL_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_join -- -runs=$(($(($RUNS * $POOL_JOIN_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz swap_exact_amount_in -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_IN_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz swap_exact_amount_out -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_OUT_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_exit -- -runs=$(($(($RUNS * $POOL_EXIT_FACT)) / $BASE)) +cargo fuzz run --profile=fuzz --fuzz-dir zrml/swaps/fuzz create_pool -- -runs=$(($(($RUNS * $CREATE_POOL_FACT)) / $BASE)) +cargo fuzz run --profile=fuzz --fuzz-dir zrml/swaps/fuzz pool_join -- -runs=$(($(($RUNS * $POOL_JOIN_FACT)) / $BASE)) +cargo fuzz run --profile=fuzz --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) +cargo fuzz run --profile=fuzz --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) +cargo fuzz run --profile=fuzz --fuzz-dir zrml/swaps/fuzz swap_exact_amount_in -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_IN_FACT)) / $BASE)) +cargo fuzz run --profile=fuzz --fuzz-dir zrml/swaps/fuzz swap_exact_amount_out -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_OUT_FACT)) / $BASE)) +cargo fuzz run --profile=fuzz --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) +cargo fuzz run --profile=fuzz --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) +cargo fuzz run --profile=fuzz --fuzz-dir zrml/swaps/fuzz pool_exit -- -runs=$(($(($RUNS * $POOL_EXIT_FACT)) / $BASE)) # --- Orderbook-v1 Pallet fuzz tests --- -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/orderbook-v1/fuzz orderbook_v1_full_workflow -- -runs=$RUNS +cargo fuzz run --fuzz-dir zrml/orderbook-v1/fuzz orderbook_v1_full_workflow -- -runs=$RUNS # --- Rikiddo Pallet fuzz tests --- -# Release is required here since it triggers debug assertions otherwise +# Profile fuzz is required here since it triggers debug assertions otherwise # Using the default RUNS multiplier, each fuzz test needs approx. 6-7 seconds -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fee_sigmoid -- -runs=$(($(($RUNS * $FEE_SIGMOID_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fixedi_to_fixedu_conversion -- -runs=$(($(($RUNS * $FIXEDI_TO_FIXEDU_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fixedu_to_fixedi_conversion -- -runs=$(($(($RUNS * $FIXEDU_TO_FIXEDI_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz balance_to_fixedu_conversion -- -runs=$(($(($RUNS * $BALANCE_TO_FIXEDU_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fixedu_to_balance_conversion -- -runs=$(($(($RUNS * $FIXEDU_TO_BALANCE_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_first_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_FIRST_STATE_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_second_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_SECOND_STATE_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_third_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_THIRD_STATE_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_estimate_ema -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_ESTIMATE_EMA_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_initial_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_INITIAL_FEE_FACT)) / $BASE)) -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_calculated_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_CALCULATED_FEE_FACT)) / $BASE)) +cargo fuzz run --profile=fuzz --fuzz-dir zrml/rikiddo/fuzz fee_sigmoid -- -runs=$(($(($RUNS * $FEE_SIGMOID_FACT)) / $BASE)) +cargo fuzz run --profile=fuzz --fuzz-dir zrml/rikiddo/fuzz fixedi_to_fixedu_conversion -- -runs=$(($(($RUNS * $FIXEDI_TO_FIXEDU_FACT)) / $BASE)) +cargo fuzz run --profile=fuzz --fuzz-dir zrml/rikiddo/fuzz fixedu_to_fixedi_conversion -- -runs=$(($(($RUNS * $FIXEDU_TO_FIXEDI_FACT)) / $BASE)) +cargo fuzz run --profile=fuzz --fuzz-dir zrml/rikiddo/fuzz balance_to_fixedu_conversion -- -runs=$(($(($RUNS * $BALANCE_TO_FIXEDU_FACT)) / $BASE)) +cargo fuzz run --profile=fuzz --fuzz-dir zrml/rikiddo/fuzz fixedu_to_balance_conversion -- -runs=$(($(($RUNS * $FIXEDU_TO_BALANCE_FACT)) / $BASE)) +cargo fuzz run --profile=fuzz --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_first_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_FIRST_STATE_FACT)) / $BASE)) +cargo fuzz run --profile=fuzz --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_second_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_SECOND_STATE_FACT)) / $BASE)) +cargo fuzz run --profile=fuzz --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_third_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_THIRD_STATE_FACT)) / $BASE)) +cargo fuzz run --profile=fuzz --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_estimate_ema -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_ESTIMATE_EMA_FACT)) / $BASE)) +cargo fuzz run --profile=fuzz --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_initial_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_INITIAL_FEE_FACT)) / $BASE)) +cargo fuzz run --profile=fuzz --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_calculated_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_CALCULATED_FEE_FACT)) / $BASE)) # This actually needs approx. 107 seconds. Need to find a way to optimize fuzzing on-chain -CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-fuzz-%p-%m.profraw' RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_pallet -- -runs=$(($(($RUNS * $RIKIDDO_PALLET_FACT)) / $BASE)) +cargo fuzz run --profile=fuzz --fuzz-dir zrml/rikiddo/fuzz rikiddo_pallet -- -runs=$(($(($RUNS * $RIKIDDO_PALLET_FACT)) / $BASE)) -grcov . --binary-path ./target/release/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o $RUNNER_TEMP/zeitgeist-fuzz-coverage.lcov +grcov . --binary-path ./target/fuzz/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o $RUNNER_TEMP/zeitgeist-fuzz-coverage.lcov diff --git a/scripts/tests/misc.sh b/scripts/tests/misc.sh index 7362ca7b2..a2dfa8b9c 100755 --- a/scripts/tests/misc.sh +++ b/scripts/tests/misc.sh @@ -24,4 +24,4 @@ do fi done -grcov . --binary-path ./target/release/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o $RUNNER_TEMP/zeitgeist-test-coverage.lcov +grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o $RUNNER_TEMP/zeitgeist-test-coverage.lcov From b741e764b4f80a62be347f8de9189aaf29145747 Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Mon, 26 Sep 2022 15:58:55 +0200 Subject: [PATCH 28/31] add fuzz coverage --- Cargo.toml | 4 --- scripts/tests/fuzz.sh | 69 ++++++++++++++++++++++++++++--------------- scripts/tests/misc.sh | 2 +- 3 files changed, 47 insertions(+), 28 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 36cfb65b5..d20aa83bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,3 @@ resolver = "2" [patch."https://github.com/purestake/moonbeam"] pallet-author-mapping = { git = "https://github.com/zeitgeistpm/moonbeam", branch = "downgrade-staking-and-mapping" } parachain-staking = { git = "https://github.com/zeitgeistpm/moonbeam", branch = "downgrade-staking-and-mapping" } - -[profile.fuzz] -inherits = "dev" -debug-assertions = false diff --git a/scripts/tests/fuzz.sh b/scripts/tests/fuzz.sh index a50923f55..e12e2ac07 100755 --- a/scripts/tests/fuzz.sh +++ b/scripts/tests/fuzz.sh @@ -33,37 +33,60 @@ RIKIDDO_WITH_CALCULATED_FEE_FACT=1750 RIKIDDO_PALLET_FACT=1000 # --- Prediction Market Pallet fuzz tests --- -cargo fuzz run --profile=fuzz --fuzz-dir zrml/prediction-markets/fuzz pm_full_workflow -- -runs=$RUNS +cargo fuzz run --fuzz-dir zrml/prediction-markets/fuzz pm_full_workflow -- -runs=$RUNS +cargo fuzz coverage --fuzz-dir zrml/prediction-markets/fuzz pm_full_workflow # --- Swaps Pallet fuzz tests --- -cargo fuzz run --profile=fuzz --fuzz-dir zrml/swaps/fuzz create_pool -- -runs=$(($(($RUNS * $CREATE_POOL_FACT)) / $BASE)) -cargo fuzz run --profile=fuzz --fuzz-dir zrml/swaps/fuzz pool_join -- -runs=$(($(($RUNS * $POOL_JOIN_FACT)) / $BASE)) -cargo fuzz run --profile=fuzz --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) -cargo fuzz run --profile=fuzz --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) -cargo fuzz run --profile=fuzz --fuzz-dir zrml/swaps/fuzz swap_exact_amount_in -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_IN_FACT)) / $BASE)) -cargo fuzz run --profile=fuzz --fuzz-dir zrml/swaps/fuzz swap_exact_amount_out -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_OUT_FACT)) / $BASE)) -cargo fuzz run --profile=fuzz --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) -cargo fuzz run --profile=fuzz --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) -cargo fuzz run --profile=fuzz --fuzz-dir zrml/swaps/fuzz pool_exit -- -runs=$(($(($RUNS * $POOL_EXIT_FACT)) / $BASE)) +cargo fuzz run --fuzz-dir zrml/swaps/fuzz create_pool -- -runs=$(($(($RUNS * $CREATE_POOL_FACT)) / $BASE)) +cargo fuzz coverage --fuzz-dir zrml/swaps/fuzz create_pool +cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_join -- -runs=$(($(($RUNS * $POOL_JOIN_FACT)) / $BASE)) +cargo fuzz coverage --fuzz-dir zrml/swaps/fuzz pool_join +cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) +cargo fuzz coverage --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_pool_amount +cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) +cargo fuzz coverage --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_asset_amount +cargo fuzz run --fuzz-dir zrml/swaps/fuzz swap_exact_amount_in -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_IN_FACT)) / $BASE)) +cargo fuzz coverage --fuzz-dir zrml/swaps/fuzz swap_exact_amount_in +cargo fuzz run --fuzz-dir zrml/swaps/fuzz swap_exact_amount_out -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_OUT_FACT)) / $BASE)) +cargo fuzz coverage --fuzz-dir zrml/swaps/fuzz swap_exact_amount_out +cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) +cargo fuzz coverage --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_asset_amount +cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) +cargo fuzz coverage --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_pool_amount +cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_exit -- -runs=$(($(($RUNS * $POOL_EXIT_FACT)) / $BASE)) +cargo fuzz coverage --fuzz-dir zrml/swaps/fuzz pool_exit # --- Orderbook-v1 Pallet fuzz tests --- cargo fuzz run --fuzz-dir zrml/orderbook-v1/fuzz orderbook_v1_full_workflow -- -runs=$RUNS +cargo fuzz coverage --fuzz-dir zrml/orderbook-v1/fuzz orderbook_v1_full_workflow # --- Rikiddo Pallet fuzz tests --- # Profile fuzz is required here since it triggers debug assertions otherwise # Using the default RUNS multiplier, each fuzz test needs approx. 6-7 seconds -cargo fuzz run --profile=fuzz --fuzz-dir zrml/rikiddo/fuzz fee_sigmoid -- -runs=$(($(($RUNS * $FEE_SIGMOID_FACT)) / $BASE)) -cargo fuzz run --profile=fuzz --fuzz-dir zrml/rikiddo/fuzz fixedi_to_fixedu_conversion -- -runs=$(($(($RUNS * $FIXEDI_TO_FIXEDU_FACT)) / $BASE)) -cargo fuzz run --profile=fuzz --fuzz-dir zrml/rikiddo/fuzz fixedu_to_fixedi_conversion -- -runs=$(($(($RUNS * $FIXEDU_TO_FIXEDI_FACT)) / $BASE)) -cargo fuzz run --profile=fuzz --fuzz-dir zrml/rikiddo/fuzz balance_to_fixedu_conversion -- -runs=$(($(($RUNS * $BALANCE_TO_FIXEDU_FACT)) / $BASE)) -cargo fuzz run --profile=fuzz --fuzz-dir zrml/rikiddo/fuzz fixedu_to_balance_conversion -- -runs=$(($(($RUNS * $FIXEDU_TO_BALANCE_FACT)) / $BASE)) -cargo fuzz run --profile=fuzz --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_first_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_FIRST_STATE_FACT)) / $BASE)) -cargo fuzz run --profile=fuzz --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_second_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_SECOND_STATE_FACT)) / $BASE)) -cargo fuzz run --profile=fuzz --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_third_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_THIRD_STATE_FACT)) / $BASE)) -cargo fuzz run --profile=fuzz --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_estimate_ema -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_ESTIMATE_EMA_FACT)) / $BASE)) -cargo fuzz run --profile=fuzz --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_initial_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_INITIAL_FEE_FACT)) / $BASE)) -cargo fuzz run --profile=fuzz --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_calculated_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_CALCULATED_FEE_FACT)) / $BASE)) +cargo fuzz run --fuzz-dir zrml/rikiddo/fuzz fee_sigmoid -- -runs=$(($(($RUNS * $FEE_SIGMOID_FACT)) / $BASE)) +cargo fuzz coverage --fuzz-dir zrml/rikiddo/fuzz fee_sigmoid +cargo fuzz run --fuzz-dir zrml/rikiddo/fuzz fixedi_to_fixedu_conversion -- -runs=$(($(($RUNS * $FIXEDI_TO_FIXEDU_FACT)) / $BASE)) +cargo fuzz coverage --fuzz-dir zrml/rikiddo/fuzz fixedi_to_fixedu_conversion +cargo fuzz run --fuzz-dir zrml/rikiddo/fuzz fixedu_to_fixedi_conversion -- -runs=$(($(($RUNS * $FIXEDU_TO_FIXEDI_FACT)) / $BASE)) +cargo fuzz coverage --fuzz-dir zrml/rikiddo/fuzz fixedu_to_fixedi_conversion +cargo fuzz run --fuzz-dir zrml/rikiddo/fuzz balance_to_fixedu_conversion -- -runs=$(($(($RUNS * $BALANCE_TO_FIXEDU_FACT)) / $BASE)) +cargo fuzz coverage --fuzz-dir zrml/rikiddo/fuzz balance_to_fixedu_conversion +cargo fuzz run --fuzz-dir zrml/rikiddo/fuzz fixedu_to_balance_conversion -- -runs=$(($(($RUNS * $FIXEDU_TO_BALANCE_FACT)) / $BASE)) +cargo fuzz coverage --fuzz-dir zrml/rikiddo/fuzz fixedu_to_balance_conversion +cargo fuzz run --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_first_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_FIRST_STATE_FACT)) / $BASE)) +cargo fuzz coverage --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_first_state +cargo fuzz run --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_second_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_SECOND_STATE_FACT)) / $BASE)) +cargo fuzz coverage --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_second_state +cargo fuzz run --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_third_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_THIRD_STATE_FACT)) / $BASE)) +cargo fuzz coverage --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_third_state +cargo fuzz run --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_estimate_ema -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_ESTIMATE_EMA_FACT)) / $BASE)) +cargo fuzz coverage --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_estimate_ema +cargo fuzz run --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_initial_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_INITIAL_FEE_FACT)) / $BASE)) +cargo fuzz coverage --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_initial_fee +cargo fuzz run --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_calculated_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_CALCULATED_FEE_FACT)) / $BASE)) +cargo fuzz coverage --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_calculated_fee # This actually needs approx. 107 seconds. Need to find a way to optimize fuzzing on-chain -cargo fuzz run --profile=fuzz --fuzz-dir zrml/rikiddo/fuzz rikiddo_pallet -- -runs=$(($(($RUNS * $RIKIDDO_PALLET_FACT)) / $BASE)) +cargo fuzz run --fuzz-dir zrml/rikiddo/fuzz rikiddo_pallet -- -runs=$(($(($RUNS * $RIKIDDO_PALLET_FACT)) / $BASE)) +cargo fuzz coverage --fuzz-dir zrml/rikiddo/fuzz rikiddo_pallet -grcov . --binary-path ./target/fuzz/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o $RUNNER_TEMP/zeitgeist-fuzz-coverage.lcov +grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" --llvm -o $RUNNER_TEMP/zeitgeist-fuzz-coverage.lcov \ No newline at end of file diff --git a/scripts/tests/misc.sh b/scripts/tests/misc.sh index a2dfa8b9c..579231ada 100755 --- a/scripts/tests/misc.sh +++ b/scripts/tests/misc.sh @@ -24,4 +24,4 @@ do fi done -grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o $RUNNER_TEMP/zeitgeist-test-coverage.lcov +grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --llvm --ignore '../*' --ignore "/*" -o $RUNNER_TEMP/zeitgeist-test-coverage.lcov From 56ebfdb7007351a1bf2aff3695d539f3de34e26b Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Tue, 27 Sep 2022 09:24:21 +0200 Subject: [PATCH 29/31] remove fuzz coverage --- .github/workflows/rust.yml | 16 +-------- scripts/tests/fuzz.sh | 73 +++++++++++++------------------------- 2 files changed, 25 insertions(+), 64 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 4e086bb99..cf8cad02e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -119,12 +119,7 @@ jobs: default: true override: true profile: minimal - components: rustfmt, clippy, llvm-tools-preview - - - uses: actions-rs/install@v0.1 - with: - crate: grcov - use-tool-cache: true + components: rustfmt, clippy - uses: actions-rs/install@v0.1 with: @@ -135,12 +130,3 @@ jobs: uses: Swatinem/rust-cache@v1 - run: ./scripts/tests/fuzz.sh - - - name: Upload to codecov.io - uses: codecov/codecov-action@v3 - with: - files: ${{ runner.temp }}/zeitgeist-fuzz-coverage.lcov - fail_ci_if_error: true - flags: fuzz - verbose: true - name: fuzz-tests diff --git a/scripts/tests/fuzz.sh b/scripts/tests/fuzz.sh index e12e2ac07..7d70922a6 100755 --- a/scripts/tests/fuzz.sh +++ b/scripts/tests/fuzz.sh @@ -33,60 +33,35 @@ RIKIDDO_WITH_CALCULATED_FEE_FACT=1750 RIKIDDO_PALLET_FACT=1000 # --- Prediction Market Pallet fuzz tests --- -cargo fuzz run --fuzz-dir zrml/prediction-markets/fuzz pm_full_workflow -- -runs=$RUNS -cargo fuzz coverage --fuzz-dir zrml/prediction-markets/fuzz pm_full_workflow +cargo fuzz run --release --fuzz-dir zrml/prediction-markets/fuzz pm_full_workflow -- -runs=$RUNS # --- Swaps Pallet fuzz tests --- -cargo fuzz run --fuzz-dir zrml/swaps/fuzz create_pool -- -runs=$(($(($RUNS * $CREATE_POOL_FACT)) / $BASE)) -cargo fuzz coverage --fuzz-dir zrml/swaps/fuzz create_pool -cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_join -- -runs=$(($(($RUNS * $POOL_JOIN_FACT)) / $BASE)) -cargo fuzz coverage --fuzz-dir zrml/swaps/fuzz pool_join -cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) -cargo fuzz coverage --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_pool_amount -cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) -cargo fuzz coverage --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_asset_amount -cargo fuzz run --fuzz-dir zrml/swaps/fuzz swap_exact_amount_in -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_IN_FACT)) / $BASE)) -cargo fuzz coverage --fuzz-dir zrml/swaps/fuzz swap_exact_amount_in -cargo fuzz run --fuzz-dir zrml/swaps/fuzz swap_exact_amount_out -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_OUT_FACT)) / $BASE)) -cargo fuzz coverage --fuzz-dir zrml/swaps/fuzz swap_exact_amount_out -cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) -cargo fuzz coverage --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_asset_amount -cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) -cargo fuzz coverage --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_pool_amount -cargo fuzz run --fuzz-dir zrml/swaps/fuzz pool_exit -- -runs=$(($(($RUNS * $POOL_EXIT_FACT)) / $BASE)) -cargo fuzz coverage --fuzz-dir zrml/swaps/fuzz pool_exit +cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz create_pool -- -runs=$(($(($RUNS * $CREATE_POOL_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_join -- -runs=$(($(($RUNS * $POOL_JOIN_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz swap_exact_amount_in -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_IN_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz swap_exact_amount_out -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_OUT_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_exit -- -runs=$(($(($RUNS * $POOL_EXIT_FACT)) / $BASE)) # --- Orderbook-v1 Pallet fuzz tests --- -cargo fuzz run --fuzz-dir zrml/orderbook-v1/fuzz orderbook_v1_full_workflow -- -runs=$RUNS -cargo fuzz coverage --fuzz-dir zrml/orderbook-v1/fuzz orderbook_v1_full_workflow +cargo fuzz run --release --fuzz-dir zrml/orderbook-v1/fuzz orderbook_v1_full_workflow -- -runs=$RUNS # --- Rikiddo Pallet fuzz tests --- -# Profile fuzz is required here since it triggers debug assertions otherwise +# Profile release is required here since it triggers debug assertions otherwise # Using the default RUNS multiplier, each fuzz test needs approx. 6-7 seconds -cargo fuzz run --fuzz-dir zrml/rikiddo/fuzz fee_sigmoid -- -runs=$(($(($RUNS * $FEE_SIGMOID_FACT)) / $BASE)) -cargo fuzz coverage --fuzz-dir zrml/rikiddo/fuzz fee_sigmoid -cargo fuzz run --fuzz-dir zrml/rikiddo/fuzz fixedi_to_fixedu_conversion -- -runs=$(($(($RUNS * $FIXEDI_TO_FIXEDU_FACT)) / $BASE)) -cargo fuzz coverage --fuzz-dir zrml/rikiddo/fuzz fixedi_to_fixedu_conversion -cargo fuzz run --fuzz-dir zrml/rikiddo/fuzz fixedu_to_fixedi_conversion -- -runs=$(($(($RUNS * $FIXEDU_TO_FIXEDI_FACT)) / $BASE)) -cargo fuzz coverage --fuzz-dir zrml/rikiddo/fuzz fixedu_to_fixedi_conversion -cargo fuzz run --fuzz-dir zrml/rikiddo/fuzz balance_to_fixedu_conversion -- -runs=$(($(($RUNS * $BALANCE_TO_FIXEDU_FACT)) / $BASE)) -cargo fuzz coverage --fuzz-dir zrml/rikiddo/fuzz balance_to_fixedu_conversion -cargo fuzz run --fuzz-dir zrml/rikiddo/fuzz fixedu_to_balance_conversion -- -runs=$(($(($RUNS * $FIXEDU_TO_BALANCE_FACT)) / $BASE)) -cargo fuzz coverage --fuzz-dir zrml/rikiddo/fuzz fixedu_to_balance_conversion -cargo fuzz run --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_first_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_FIRST_STATE_FACT)) / $BASE)) -cargo fuzz coverage --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_first_state -cargo fuzz run --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_second_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_SECOND_STATE_FACT)) / $BASE)) -cargo fuzz coverage --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_second_state -cargo fuzz run --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_third_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_THIRD_STATE_FACT)) / $BASE)) -cargo fuzz coverage --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_third_state -cargo fuzz run --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_estimate_ema -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_ESTIMATE_EMA_FACT)) / $BASE)) -cargo fuzz coverage --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_estimate_ema -cargo fuzz run --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_initial_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_INITIAL_FEE_FACT)) / $BASE)) -cargo fuzz coverage --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_initial_fee -cargo fuzz run --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_calculated_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_CALCULATED_FEE_FACT)) / $BASE)) -cargo fuzz coverage --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_calculated_fee +cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fee_sigmoid -- -runs=$(($(($RUNS * $FEE_SIGMOID_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fixedi_to_fixedu_conversion -- -runs=$(($(($RUNS * $FIXEDI_TO_FIXEDU_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fixedu_to_fixedi_conversion -- -runs=$(($(($RUNS * $FIXEDU_TO_FIXEDI_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz balance_to_fixedu_conversion -- -runs=$(($(($RUNS * $BALANCE_TO_FIXEDU_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fixedu_to_balance_conversion -- -runs=$(($(($RUNS * $FIXEDU_TO_BALANCE_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_first_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_FIRST_STATE_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_second_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_SECOND_STATE_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_third_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_THIRD_STATE_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_estimate_ema -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_ESTIMATE_EMA_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_initial_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_INITIAL_FEE_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_calculated_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_CALCULATED_FEE_FACT)) / $BASE)) # This actually needs approx. 107 seconds. Need to find a way to optimize fuzzing on-chain -cargo fuzz run --fuzz-dir zrml/rikiddo/fuzz rikiddo_pallet -- -runs=$(($(($RUNS * $RIKIDDO_PALLET_FACT)) / $BASE)) -cargo fuzz coverage --fuzz-dir zrml/rikiddo/fuzz rikiddo_pallet - -grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" --llvm -o $RUNNER_TEMP/zeitgeist-fuzz-coverage.lcov \ No newline at end of file +cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_pallet -- -runs=$(($(($RUNS * $RIKIDDO_PALLET_FACT)) / $BASE)) From 684c124a0d2d65d60736b31772d4d79dcd111d53 Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Tue, 27 Sep 2022 09:26:10 +0200 Subject: [PATCH 30/31] add RUST_BACKTRACE to cargo fuzz --- scripts/tests/fuzz.sh | 46 +++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/scripts/tests/fuzz.sh b/scripts/tests/fuzz.sh index 7d70922a6..dc7b3588b 100755 --- a/scripts/tests/fuzz.sh +++ b/scripts/tests/fuzz.sh @@ -33,35 +33,35 @@ RIKIDDO_WITH_CALCULATED_FEE_FACT=1750 RIKIDDO_PALLET_FACT=1000 # --- Prediction Market Pallet fuzz tests --- -cargo fuzz run --release --fuzz-dir zrml/prediction-markets/fuzz pm_full_workflow -- -runs=$RUNS +RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/prediction-markets/fuzz pm_full_workflow -- -runs=$RUNS # --- Swaps Pallet fuzz tests --- -cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz create_pool -- -runs=$(($(($RUNS * $CREATE_POOL_FACT)) / $BASE)) -cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_join -- -runs=$(($(($RUNS * $POOL_JOIN_FACT)) / $BASE)) -cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) -cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) -cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz swap_exact_amount_in -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_IN_FACT)) / $BASE)) -cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz swap_exact_amount_out -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_OUT_FACT)) / $BASE)) -cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) -cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) -cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_exit -- -runs=$(($(($RUNS * $POOL_EXIT_FACT)) / $BASE)) +RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz create_pool -- -runs=$(($(($RUNS * $CREATE_POOL_FACT)) / $BASE)) +RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_join -- -runs=$(($(($RUNS * $POOL_JOIN_FACT)) / $BASE)) +RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) +RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) +RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz swap_exact_amount_in -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_IN_FACT)) / $BASE)) +RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz swap_exact_amount_out -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_OUT_FACT)) / $BASE)) +RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) +RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) +RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_exit -- -runs=$(($(($RUNS * $POOL_EXIT_FACT)) / $BASE)) # --- Orderbook-v1 Pallet fuzz tests --- -cargo fuzz run --release --fuzz-dir zrml/orderbook-v1/fuzz orderbook_v1_full_workflow -- -runs=$RUNS +RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/orderbook-v1/fuzz orderbook_v1_full_workflow -- -runs=$RUNS # --- Rikiddo Pallet fuzz tests --- # Profile release is required here since it triggers debug assertions otherwise # Using the default RUNS multiplier, each fuzz test needs approx. 6-7 seconds -cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fee_sigmoid -- -runs=$(($(($RUNS * $FEE_SIGMOID_FACT)) / $BASE)) -cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fixedi_to_fixedu_conversion -- -runs=$(($(($RUNS * $FIXEDI_TO_FIXEDU_FACT)) / $BASE)) -cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fixedu_to_fixedi_conversion -- -runs=$(($(($RUNS * $FIXEDU_TO_FIXEDI_FACT)) / $BASE)) -cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz balance_to_fixedu_conversion -- -runs=$(($(($RUNS * $BALANCE_TO_FIXEDU_FACT)) / $BASE)) -cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fixedu_to_balance_conversion -- -runs=$(($(($RUNS * $FIXEDU_TO_BALANCE_FACT)) / $BASE)) -cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_first_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_FIRST_STATE_FACT)) / $BASE)) -cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_second_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_SECOND_STATE_FACT)) / $BASE)) -cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_third_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_THIRD_STATE_FACT)) / $BASE)) -cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_estimate_ema -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_ESTIMATE_EMA_FACT)) / $BASE)) -cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_initial_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_INITIAL_FEE_FACT)) / $BASE)) -cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_calculated_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_CALCULATED_FEE_FACT)) / $BASE)) +RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fee_sigmoid -- -runs=$(($(($RUNS * $FEE_SIGMOID_FACT)) / $BASE)) +RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fixedi_to_fixedu_conversion -- -runs=$(($(($RUNS * $FIXEDI_TO_FIXEDU_FACT)) / $BASE)) +RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fixedu_to_fixedi_conversion -- -runs=$(($(($RUNS * $FIXEDU_TO_FIXEDI_FACT)) / $BASE)) +RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz balance_to_fixedu_conversion -- -runs=$(($(($RUNS * $BALANCE_TO_FIXEDU_FACT)) / $BASE)) +RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fixedu_to_balance_conversion -- -runs=$(($(($RUNS * $FIXEDU_TO_BALANCE_FACT)) / $BASE)) +RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_first_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_FIRST_STATE_FACT)) / $BASE)) +RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_second_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_SECOND_STATE_FACT)) / $BASE)) +RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_third_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_THIRD_STATE_FACT)) / $BASE)) +RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_estimate_ema -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_ESTIMATE_EMA_FACT)) / $BASE)) +RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_initial_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_INITIAL_FEE_FACT)) / $BASE)) +RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_calculated_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_CALCULATED_FEE_FACT)) / $BASE)) # This actually needs approx. 107 seconds. Need to find a way to optimize fuzzing on-chain -cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_pallet -- -runs=$(($(($RUNS * $RIKIDDO_PALLET_FACT)) / $BASE)) +RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_pallet -- -runs=$(($(($RUNS * $RIKIDDO_PALLET_FACT)) / $BASE)) From 0759863aa4a8203b6c4cac28871bd5175eab9951 Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Tue, 27 Sep 2022 09:40:53 +0200 Subject: [PATCH 31/31] update cargo test comment --- scripts/tests/aux-functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/tests/aux-functions.sh b/scripts/tests/aux-functions.sh index 24eca780a..5847fdd9f 100755 --- a/scripts/tests/aux-functions.sh +++ b/scripts/tests/aux-functions.sh @@ -15,6 +15,6 @@ test_package_with_feature() { local features=$2 /bin/echo -e "\e[0;33m***** Testing '$package' with features '$features' *****\e[0m\n" - # default rustc profile dev is used to get better test coverage reports + # default rustc profile dev (debug) is used to stop for debug_assertions CARGO_INCREMENTAL=0 RUSTFLAGS="-Cinstrument-coverage" LLVM_PROFILE_FILE="cargo-test-%p-%m.profraw" cargo test --features $features --manifest-path $package/Cargo.toml --no-default-features }