Skip to content

fix(p2p): restore ABCI IP-based peer filtering dropped in #1248 - #1364

Merged
lklimek merged 1 commit into
v1.6-devfrom
fix/1248-filter-peer-by-ip
Jun 22, 2026
Merged

lklimek merged 1 commit into
v1.6-devfrom
fix/1248-filter-peer-by-ip

Conversation

@lklimek

@lklimek lklimek commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Restores the ABCI /p2p/filter/addr/%s IP-based peer filter (opts.FilterPeerByIP) that was inadvertently dropped in #1248, re-enabling operator address-based peer rejection via the ABCI app.

Tests

  • TestGetRouterConfigFilterPeerByIP (6 subtests)

🤖 Generated with Claude Code

PR #1248 rewrote getRouterConfig to add allowlist-only composition via
chainFilterByID, but silently omitted opts.FilterPeerByIP. The router
still calls filterPeersIP when that option is non-nil, so ABCI apps that
ban peers by IP address (/p2p/filter/addr/<ip:port>) lost that control
without any observable error on upgrade.

Restore the FilterPeerByIP closure inside the
`conf.FilterPeers && appClient != nil` branch, matching v1.5.4 semantics:
issue a Query for /p2p/filter/addr/<ip:port>, reject the peer on any
non-OK response or transport error. The allowlist / chainFilterByID logic
introduced by #1248 is left intact.

Add TestGetRouterConfigFilterPeerByIP with six subtests covering:
- non-nil assertion when filtering is enabled with an app client
- nil when filtering is disabled or app client is absent
- closure accepts a peer on OK ABCI response
- closure rejects a peer on non-OK ABCI response
- closure propagates ABCI transport errors as rejections

Refs: #1248, audit finding GO-004 / SEC MEDIUM

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lklimek
lklimek requested a review from QuantumExplorer as a code owner June 22, 2026 08:09
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e8e0765c-b1bf-4986-9f63-03d423bd5225

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/1248-filter-peer-by-ip

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

thepastaclaw commented Jun 22, 2026 •

Copy link
Copy Markdown

✅ Review complete (commit c292278)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR restores the ABCI-based IP/addr peer filtering hook (opts.FilterPeerByIP) in the node’s P2P router options, which was inadvertently removed in PR #1248. This re-enables operators/apps to reject peers based on their IP address (and port) via ABCI query endpoints.

Changes:

  • Reintroduced wiring for RouterOptions.FilterPeerByIP when FilterPeers is enabled and an ABCI client is available.
  • Implemented the ABCI query path /p2p/filter/addr/<ip:port> for the IP filter closure.
  • Added a regression unit test suite (TestGetRouterConfigFilterPeerByIP) covering enabled/disabled behavior and OK/non-OK/error ABCI responses.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
node/node.go Restores FilterPeerByIP by querying the ABCI app on incoming connections using the /p2p/filter/addr/... path.
node/node_test.go Adds regression tests verifying the filter is wired correctly and queries the expected ABCI path, including error cases.

Comment thread node/node.go

@thepastaclaw thepastaclaw 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.

Code Review

PR #1364 narrowly restores the opts.FilterPeerByIP closure dropped by #1248, re-wiring the ABCI /p2p/filter/addr/<ip:port> peer rejection path with byte-equivalent semantics to v1.5.4 (IPv6-safe net.JoinHostPort, fail-closed on transport error and non-OK ABCI response, properly gated on conf.FilterPeers && appClient != nil). Both independent agents converged on no in-scope findings; the diff at node/node.go:781-797 matches the stated intent and is exercised by six focused subtests. Approving.

@lklimek
lklimek merged commit 95c9f7d into v1.6-dev Jun 22, 2026
18 checks passed
@lklimek
lklimek deleted the fix/1248-filter-peer-by-ip branch June 22, 2026 10:30
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.

3 participants