Skip to content

Commit 83e9e80

Browse files
authored
Merge pull request #3691 from TheBlueMatt/2025-03-fuzz-less
Reduce CI fuzz iterations as we're now timing out
2 parents d2ffeff + 57c0d26 commit 83e9e80

File tree

7 files changed

+674
-626
lines changed

7 files changed

+674
-626
lines changed

.github/workflows/build.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,12 @@ jobs:
262262
sudo apt-get -y install build-essential binutils-dev libunwind-dev
263263
- name: Pin the regex dependency
264264
run: |
265-
cd fuzz && cargo update -p regex --precise "1.9.6" --verbose && cd ..
265+
cd fuzz && cargo update -p regex --precise "1.9.6" --verbose
266+
cd write-seeds && cargo update -p regex --precise "1.9.6" --verbose
266267
- name: Sanity check fuzz targets on Rust ${{ env.TOOLCHAIN }}
267268
run: |
268269
cd fuzz
269-
RUSTFLAGS="--cfg=fuzzing --cfg=secp256k1_fuzz --cfg=hashes_fuzz" cargo test --verbose --color always
270+
RUSTFLAGS="--cfg=fuzzing --cfg=secp256k1_fuzz --cfg=hashes_fuzz" cargo test --verbose --color always --lib --bins
270271
cargo clean
271272
- name: Run fuzzers
272273
run: cd fuzz && ./ci-fuzz.sh && cd ..

fuzz/ci-fuzz.sh

+16-5
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,19 @@ rm *_target.rs
1313
[ "$(git diff)" != "" ] && exit 1
1414
popd
1515

16+
export RUSTFLAGS="--cfg=secp256k1_fuzz --cfg=hashes_fuzz"
17+
18+
mkdir -p hfuzz_workspace/full_stack_target/input
19+
pushd write-seeds
20+
RUSTFLAGS="$RUSTFLAGS --cfg=fuzzing" cargo run ../hfuzz_workspace/full_stack_target/input
21+
popd
22+
1623
cargo install --color always --force honggfuzz --no-default-features
24+
# Because we're fuzzing relatively few iterations, the maximum possible
25+
# compiler optimizations aren't necessary, so switch to defaults.
1726
sed -i 's/lto = true//' Cargo.toml
27+
sed -i 's/codegen-units = 1//' Cargo.toml
1828

19-
export RUSTFLAGS="--cfg=secp256k1_fuzz --cfg=hashes_fuzz"
2029
export HFUZZ_BUILD_ARGS="--features honggfuzz_fuzz"
2130

2231
cargo --color always hfuzz build
@@ -25,11 +34,13 @@ for TARGET in src/bin/*.rs; do
2534
FILE="${FILENAME%.*}"
2635
HFUZZ_RUN_ARGS="--exit_upon_crash -v -n2"
2736
if [ "$FILE" = "chanmon_consistency_target" ]; then
28-
HFUZZ_RUN_ARGS="$HFUZZ_RUN_ARGS -F 64 -N100000"
29-
elif [ "$FILE" = "full_stack_target" ]; then
30-
HFUZZ_RUN_ARGS="$HFUZZ_RUN_ARGS -t0 -N1000000"
37+
HFUZZ_RUN_ARGS="$HFUZZ_RUN_ARGS -F 64 -N5000"
38+
elif [ "$FILE" = "process_network_graph_target" -o "$FILE" = "full_stack_target" -o "$FILE" = "router_target" ]; then
39+
HFUZZ_RUN_ARGS="$HFUZZ_RUN_ARGS -N50000"
40+
elif [ "$FILE" = "indexedmap_target" ]; then
41+
HFUZZ_RUN_ARGS="$HFUZZ_RUN_ARGS -N500000"
3142
else
32-
HFUZZ_RUN_ARGS="$HFUZZ_RUN_ARGS -N1000000"
43+
HFUZZ_RUN_ARGS="$HFUZZ_RUN_ARGS -N2500000"
3344
fi
3445
export HFUZZ_RUN_ARGS
3546
cargo --color always hfuzz run $FILE

fuzz/src/full_stack.rs

+624-618
Large diffs are not rendered by default.

fuzz/src/lib.rs

+9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ extern crate bitcoin;
1111
extern crate lightning;
1212
extern crate lightning_rapid_gossip_sync;
1313

14+
#[cfg(not(fuzzing))]
15+
compile_error!("Fuzz targets need cfg=fuzzing");
16+
17+
#[cfg(not(hashes_fuzz))]
18+
compile_error!("Fuzz targets need cfg=hashes_fuzz");
19+
20+
#[cfg(not(secp256k1_fuzz))]
21+
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");
22+
1423
pub mod utils;
1524

1625
pub mod base32;

fuzz/write-seeds/Cargo.toml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "lightning-fuzz-write-seeds"
3+
version = "0.0.1"
4+
authors = ["Automatically generated"]
5+
publish = false
6+
edition = "2021"
7+
8+
[features]
9+
10+
[dependencies]
11+
lightning-fuzz = { path = "../" }
12+
13+
# Prevent this from interfering with workspaces
14+
[workspace]
15+
members = ["."]

fuzz/write-seeds/src/main.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fn main() {
2+
let mut iter = std::env::args();
3+
iter.next().unwrap(); // program name
4+
let path = iter.next().expect("Requires a path as the first argument");
5+
lightning_fuzz::full_stack::write_fst_seeds(&path);
6+
}

lightning/src/routing/gossip.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1786,7 +1786,7 @@ where
17861786
}
17871787

17881788
fn test_node_counter_consistency(&self) {
1789-
#[cfg(test)]
1789+
#[cfg(any(test, fuzzing))]
17901790
{
17911791
let channels = self.channels.read().unwrap();
17921792
let nodes = self.nodes.read().unwrap();

0 commit comments

Comments
 (0)