Skip to content

fix: ignore repeated getsporks requests#7343

Open
thepastaclaw wants to merge 1 commit into
dashpay:developfrom
thepastaclaw:fix/getsporks-once
Open

fix: ignore repeated getsporks requests#7343
thepastaclaw wants to merge 1 commit into
dashpay:developfrom
thepastaclaw:fix/getsporks-once

Conversation

@thepastaclaw

Copy link
Copy Markdown

Pull request

Issue being fixed or feature implemented

getsporks currently responds to every request from a connected peer by
snapshotting active sporks and sending each stored spork message back. The active
spork set is small, so this is low impact, but repeated requests are unnecessary
resource use and keep being flagged by security-audit tooling.

This PR makes getsporks follow the existing getaddr pattern: answer once per
connection and ignore repeats.

What was done?

  • Added per-peer m_getsporks_recvd state.
  • Ignore repeated getsporks requests on the same connection after the first
    response.
  • Added a functional regression test in feature_sporks.py that sends
    getsporks twice and verifies only the first request returns spork messages.

How Has This Been Tested?

Tested on macOS arm64 using the existing depends prefix.

  • git diff --check
  • python3 -m py_compile test/functional/feature_sporks.py
  • make -j8 src/dashd
  • test/functional/feature_sporks.py --tmpdir=/Users/claw/.openclaw/workspace/tmp-dash-test-feature-sporks-rerun-79105

The focused functional test passed successfully.

Breaking Changes

None.

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone

@thepastaclaw

Copy link
Copy Markdown
Author

@coderabbitai review

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

✅ No Merge Conflicts Detected

This PR currently has no conflicts with other open PRs.

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

PastaPastaPasta
PastaPastaPasta previously approved these changes Jun 8, 2026

@PastaPastaPasta PastaPastaPasta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems reasonable to me; utACK 7c79976

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: fa8299c7-6164-4532-a874-3d4bac2fbee0

📥 Commits

Reviewing files that changed from the base of the PR and between 59ac8d3 and 60efd84.

📒 Files selected for processing (2)
  • src/net_processing.cpp
  • test/functional/feature_sporks.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/net_processing.cpp

Walkthrough

Per-peer GETSPORKS state is tracked and GETSPORKS responses are suppressed when the currently-active spork-hash set equals the last response sent to that connection. The change adds an include, two Peer fields (m_getsporks_recvd and m_getsporks_last_response), and updates the GETSPORKS handler to compute a sorted active-spork-hash list, compare it to the peer's cached list, early-return when identical, and refresh the cache when sending. A functional test sends GETSPORKS twice on one connection and asserts only one spork response was delivered; changing a spork causes a refreshed response.

Sequence Diagram(s)

sequenceDiagram
  participant PeerConn as Peer
  participant Handler as GETSPORKS_Handler
  participant SporkSet as ActiveSporkSet
  participant SporkSender as Spork_Response
  PeerConn->>Handler: GETSPORKS
  Handler->>SporkSet: Build sorted active spork hashes
  Handler->>PeerConn: Read m_getsporks_recvd & m_getsporks_last_response
  alt active set == last_response && m_getsporks_recvd == true
    Handler-->>PeerConn: Log + early return (no spork messages)
  else
    Handler->>PeerConn: Update m_getsporks_recvd = true and m_getsporks_last_response
    Handler->>SporkSender: Send active spork messages
    SporkSender-->>PeerConn: spork messages
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: implementing logic to ignore repeated getsporks requests, which is the core objective of the PR.
Description check ✅ Passed The description is directly related to the changeset, explaining the problem, the solution, implementation details, testing performed, and breaking changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
src/net_processing.cpp

src/net_processing.cpp:6:10: error: 'net_processing.h' file not found with include; use "quotes" instead
6 | #include <net_processing.h>
| ^~~~~~~~~~~~~~~~~~
| "net_processing.h"
In file included from src/net_processing.cpp:6:
src/net_processing.h:9:10: error: 'net.h' file not found with include; use "quotes" instead
9 | #include <net.h>
| ^~~~~~~
| "net.h"
In file included from src/net_processing.cpp:6:
In file included from src/net_processing.h:9:
src/net.h:9:10: error: 'bip324.h' file not found with include; use "quotes" instead
9 | #include <bip324.h>
| ^~~~~~~~~~
| "bip324.h"
In file included from src/net_processing.cpp:6:
In file included from src/net_processing.h:9:
In file included from src/net.h:9:
src/bip324.h:12:10: error: 'crypto/chacha20.h' file not found with include; use "quotes" instead
12 | #include <crypto/chacha20.h>
|

... [truncated 2200 characters] ...

__CTrans.CTrans_funct.get_clang_stmt_trans in file "src/clang/cTrans.ml" (inlined), line 5395, characters 4-69
Called from ClangFrontend__CTrans.CTrans_funct.get_custom_stmt_trans in file "src/clang/cTrans.ml", line 5401, characters 8-55
Called from ClangFrontend__CTrans.CTrans_funct.exec_trans_instrs.exec_trans_instrs_rev in file "src/clang/cTrans.ml" (inlined), line 5365, characters 28-54
Called from ClangFrontend__CTrans.CTrans_funct.exec_trans_instrs in file "src/clang/cTrans.ml" (inlined), line 5389, characters 6-70
Called from ClangFrontend__CTrans.CTrans_funct.instructions_trans in file "src/clang/cTrans.ml", line 5451, characters 25-68
Called from ClangFrontend__CFrontend_decl.CFrontend_decl_funct.add_method.f in file "src/clang/cFrontend_decl.ml", line 48, characters 12-91
Called


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.

@thepastaclaw

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@thepastaclaw

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@thepastaclaw

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/functional/feature_sporks.py`:
- Around line 91-96: The test records peer.message_count["spork"] too early
because wait_until only waits for the first spork; call peer.sync_with_ping()
immediately after wait_until (before reading spork_responses) to ensure all
spork messages from the first msg_getsporks() have been delivered; update the
block around peer.wait_until(...), peer.sync_with_ping(), and spork_responses so
spork_responses = peer.message_count["spork"] happens only after the
sync_with_ping() completes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5a4f030e-5dfd-401c-9e91-49f0b73dbdc8

📥 Commits

Reviewing files that changed from the base of the PR and between b965f90 and 59ac8d3.

📒 Files selected for processing (2)
  • src/net_processing.cpp
  • test/functional/feature_sporks.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/net_processing.cpp

Comment thread test/functional/feature_sporks.py
@thepastaclaw

thepastaclaw commented Jun 8, 2026

Copy link
Copy Markdown
Author

✅ Review complete (commit 60efd84)

@thepastaclaw

Copy link
Copy Markdown
Author

Addressed CodeRabbit race concern in the functional test by syncing after the initial getsporks response before recording the baseline count. Validation: test/functional/feature_sporks.py.

@thepastaclaw

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@thepastaclaw thepastaclaw marked this pull request as ready for review June 9, 2026 03:07

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

Verified the per-peer getsporks ignore logic in src/net_processing.cpp:5454-5481 and the functional test in test/functional/feature_sporks.py. The implementation correctly suppresses duplicate responses while still re-answering when the active spork hash set changes, and the test exercises both paths. Claude's three findings are all low-confidence nitpicks/meta observations that don't merit public review noise; Codex correctly found nothing to flag.

Note: GitHub does not allow the review bot account to approve its own PR, so this clean verification is posted as a comment review instead of an approval.

@PastaPastaPasta PastaPastaPasta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 60efd84

@PastaPastaPasta

Copy link
Copy Markdown
Member

@thepastaclaw I'm not fully sure this is worth it. Please review to confirm this makes sense to do holistically. provide justification which ever way you decide

@thepastaclaw

Copy link
Copy Markdown
Author

Reviewed this holistically and I still think it is worth keeping, with the caveat that it is a small hardening/cleanup rather than an urgent bug fix.

Why I think it makes sense:

  • getsporks is effectively a snapshot request; answering unchanged repeats on the same connection does not add useful protocol value.
  • This matches the existing getaddr anti-repeat shape and avoids leaving a low-cost request that can repeatedly trigger response fanout.
  • The implementation stays bounded: one boolean plus the last response hash set per peer, and it still re-answers on the same connection when the active spork set changes.
  • The behavior is covered by the focused functional test: first request gets sporks, unchanged repeat gets none, post-update request gets a fresh response.

Why it is not a high-priority fix:

  • The active spork set is small today, so the practical resource impact is low.
  • If maintainers prefer avoiding even small peer-state churn for marginal hardening, closing it would also be defensible.

My recommendation is to keep/merge it as a modest DoS-surface cleanup because it aligns with existing peer-request hygiene without breaking legitimate refreshed getsporks use.

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