Skip to content

Conversation

@galt-tr
Copy link
Contributor

@galt-tr galt-tr commented Nov 25, 2025

This pull request introduces support for reporting invalid subtrees in the P2P service, along with refactoring and test coverage improvements. The main changes include adding a ReportInvalidSubtree method to the P2P client and interface, implementing the corresponding gRPC handler and server logic, updating tests to cover these new code paths, and making minor refactors to method names for consistency. Additionally, there are updates to generated protobuf files to match a previous protoc compiler version.

P2P Service Enhancements:

  • Added ReportInvalidSubtree method to the P2P client (Client.go) and interface (Interface.go), allowing clients to report subtrees that failed validation, which decreases the reputation score of the peer that provided them. [1] [2]
  • Implemented a mock for ReportInvalidSubtree in test client and updated related tests to ensure proper coverage and behavior. [1] [2]
  • Added a gRPC endpoint handler for ReportInvalidSubtree and corresponding integration test to verify correct updates to peer metrics.
  • Refactored server logic to use a new internal reportInvalidSubtree method, improving clarity and error handling, and updated all usages and tests accordingly. [1] [2] [3]

Protobuf and Generated Code Updates:

Test and Code Consistency Improvements:

  • Updated all tests and usages to use the new method names (ReportValidSubtreeHandler and reportInvalidSubtree) for clarity and consistency. [1] [2] [3] [4]

These changes improve the robustness of the P2P reputation system by allowing explicit reporting and handling of invalid subtrees, and ensure the codebase and tests remain consistent and up-to-date.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 25, 2025

🤖 Claude Code Review

Status: Complete

Issues Found:

  1. Error message bug (services/p2p/Client.go:550) - The error message says "failed to report valid subtree" but should say "failed to report invalid subtree" since this is the ReportInvalidSubtree method.

  2. Signature mismatch (services/rpc/handlers_additional_test.go:5233) - The mockP2PClient.ReportInvalidSubtree method has wrong signature. Missing the reason string parameter that the interface requires. This will cause compilation errors.

  3. Missing validation (services/p2p/handler.go:56) - ReportInvalidSubtreeHandler lacks input validation present in ReportValidSubtreeHandler. Should validate req.PeerId, req.SubtreeHash, req.Reason are not empty, and check s.peerRegistry != nil.

Overall Assessment:

The PR adds useful functionality for reporting invalid subtrees to improve peer reputation tracking. The core logic appears sound, but the three issues above should be addressed before merging to prevent bugs and compilation errors.

@galt-tr galt-tr changed the title Invalid subtree peer Invalid subtree processing decreases peer reputation Nov 25, 2025
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.

1 participant