Skip to content

Commit

Permalink
feat(runtime-fuzzer): Optionally enable fuzzer logs (#3229)
Browse files Browse the repository at this point in the history
  • Loading branch information
techraed authored Sep 7, 2023
1 parent 103a8bf commit 9c515ef
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
8 changes: 0 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,6 @@ doc:
-p pallet-gear-program -p pallet-gear-rpc-runtime-api -p pallet-gear-rpc -p pallet-gear-scheduler -p gsdk
@ cp -f images/logo.svg target/doc/rust-logo.svg

.PHONY: fuzz
fuzz:
@ ./scripts/gear.sh test fuzz $(target)

.PHONY: fuzz-vara #TODO 2434 test it works
fuzz-vara:
@ ./scripts/gear.sh test fuzz --features=vara-native,lazy-pages --no-default-features $(target)

.PHONY: kill-gear
kill:
@ pkill -f 'gear |gear$' -9
Expand Down
2 changes: 1 addition & 1 deletion scripts/check-fuzzer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ main() {
dd if=/dev/urandom of=utils/runtime-fuzzer/fuzz/corpus/main/check-fuzzer-bytes bs=1 count=27000000

echo " >> Running fuzzer with failpoint"
RUST_BACKTRACE=1 FAILPOINTS=fail_fuzzer=return ./scripts/gear.sh test fuzz > fuzz_run 2>&1
RUST_BACKTRACE=1 FAILPOINTS=fail_fuzzer=return ./scripts/gear.sh test fuzz "" wlogs > fuzz_run 2>&1

echo " >> Checking fuzzer output"
if cat fuzz_run | grep -qzP '(?s)(?=.*GasTree corrupted)(?=.*NodeAlreadyExists)(?=.*\Qpallet_gear::pallet::Pallet<T>>::consume_and_retrieve\E)' ; then
Expand Down
2 changes: 1 addition & 1 deletion scripts/gear.sh
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ case "$COMMAND" in

fuzz)
header "Running fuzzer for runtime panic checks"
run_fuzzer "$ROOT_DIR" "$1"; ;;
run_fuzzer "$ROOT_DIR" "$1" "$2"; ;;

fuzz-repr)
header "Running fuzzer reproduction"
Expand Down
13 changes: 10 additions & 3 deletions scripts/src/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ test_usage() {
gcli run gcli package tests
pallet run pallet-gear tests
client run client tests via gclient
fuzz run fuzzer with a fuzz target
fuzz run fuzzer
The scripts accepts a path to corpus dir as a first param,
and a "wlogs" flag to enable logs while fuzzing.
fuzz-repr run fuzzer reproduction test
syscalls run syscalls integrity test in benchmarking module of pallet-gear
docs run doc tests
Expand Down Expand Up @@ -85,9 +87,14 @@ run_fuzzer() {
# Navigate to fuzzer dir
cd $ROOT_DIR/utils/runtime-fuzzer

if [ "$3" = "wlogs" ]; then
LOG_TARGETS="debug,syscalls,gear_wasm_gen=trace,runtime_fuzzer=trace,gear_backend_common=trace"
else
LOG_TARGETS="off"
fi

# Run fuzzer
RUST_LOG=debug,syscalls,gear_wasm_gen=trace,runtime_fuzzer=trace,gear_backend_common=trace \
cargo fuzz run --release --sanitizer=none main $CORPUS_DIR -- -rss_limit_mb=8192 -max_len=35000000 -len_control=0
RUST_LOG="$LOG_TARGETS" cargo fuzz run --release --sanitizer=none main $CORPUS_DIR -- -rss_limit_mb=8192 -max_len=35000000 -len_control=0
}

test_fuzzer_reproduction() {
Expand Down

0 comments on commit 9c515ef

Please sign in to comment.