Skip to content

Conversation

@DashCoreAutoGuix
Copy link
Owner

@DashCoreAutoGuix DashCoreAutoGuix commented Dec 9, 2025

Backports bitcoin#26561

Original commit: 93cae70

Summary

This is a move-only refactoring commit that moves net-related fuzz utilities from src/test/fuzz/util.cpp and src/test/fuzz/util.h to src/test/fuzz/util/net.cpp and src/test/fuzz/util/net.h.

Changes

  • Moved FuzzedSock class and its implementations to util/net.cpp/util/net.h
  • Moved network-related helper functions (ConsumeAddress, ConsumeSubNet, ConsumeService, ConsumeNode, FillNode) to util/net.cpp/util/net.h
  • Added necessary #include <test/fuzz/util/net.h> to fuzz tests that use these utilities
  • Added #include <util/check.h> to pow.cpp fuzz test as a side effect of the refactoring

Dash-specific adaptations

  • Updated FuzzedSock method signatures to match Dash's Sock class API:
    • IsSelectable(bool is_select) instead of IsSelectable()
    • Wait(..., SocketEventsParams event_params, ...) instead of Wait(...)
    • WaitMany(..., SocketEventsParams event_params) instead of WaitMany(...)
  • Excluded files that don't exist in Dash (ci/, i2p.cpp, mempool util files)

Summary by CodeRabbit

  • Refactor

    • Reorganized network fuzzing utilities from the main testing module into a dedicated network-specific module.
  • Tests

    • Updated multiple fuzz test files (net permissions, node eviction, message processing, SOCKS5) to use the new network fuzzing module.

✏️ Tip: You can customize this high-level summary in your review settings.

fa3b2cf fuzz: Move-only net utils (MarcoFalke)

Pull request description:

  This should speed up fuzz builds when `src/test/fuzz/util.h` is modified. Also, it makes sense on its own.

ACKs for top commit:
  dergoegge:
    ACK fa3b2cf

Tree-SHA512: 03d6abeb728ac8eb3f28167e8ac43d8d6e7e1b1738ec14f58a36e17502081fdde2d56f2d47a9e11b991754667e83b2eb22d154e394c0c1c4ffa0945db86b7e21
@coderabbitai
Copy link

coderabbitai bot commented Dec 9, 2025

Walkthrough

This pull request refactors network-related fuzzing utilities by moving the FuzzedSock class and associated consumer functions (ConsumeAddress, ConsumeNode, FillNode, etc.) from src/test/fuzz/util.{h,cpp} into dedicated new files src/test/fuzz/util/net.{h,cpp}. Multiple fuzz test files are updated to include the relocated utilities from their new location.

Changes

Cohort / File(s) Summary
Network fuzzing utilities refactoring
src/test/fuzz/util.h, src/test/fuzz/util.cpp
Removed FuzzedSock class, ConsumeAddress, ConsumeSock, ConsumeSubNet, ConsumeService, ConsumeNode variants, and FillNode function along with related network-specific includes. Utilities relocated to dedicated net module.
New network fuzzing module
src/test/fuzz/util/net.h, src/test/fuzz/util/net.cpp
New module files introduced with complete FuzzedSock class implementation including socket operation overrides, factory functions (ConsumeSock, ConsumeSubNet, ConsumeService, ConsumeAddress), node consumer templates (ConsumeNode, ConsumeNodeAsUniquePtr), and FillNode utility with fuzzed error handling and latency simulation.
Fuzz test includes update
src/test/fuzz/net.cpp, src/test/fuzz/net_permissions.cpp, src/test/fuzz/node_eviction.cpp, src/test/fuzz/pow.cpp, src/test/fuzz/process_message.cpp, src/test/fuzz/process_messages.cpp, src/test/fuzz/socks5.cpp
Added #include <test/fuzz/util/net.h> directive to enable access to network fuzzing utilities.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

  • Verify that all code removed from src/test/fuzz/util.{h,cpp} is correctly and completely transplanted to src/test/fuzz/util/net.{h,cpp} with no gaps or omissions
  • Confirm that the new net module has all necessary includes and that no circular dependency issues are introduced
  • Check that the FuzzedSock implementation (particularly the errno handling and MSG_PEEK logic) is functionally equivalent to the original
  • Validate that all seven fuzz test files' include paths are correct and that the new module structure is discoverable by the build system

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: moving net utilities from general util files to a dedicated util/net module, which is the primary refactor objective.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch backport-0.25-batch-488-pr-26561

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants