-
Notifications
You must be signed in to change notification settings - Fork 97
fix(hopr-lib): Connectability issues in the local cluster and production #7255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(hopr-lib): Connectability issues in the local cluster and production #7255
Conversation
Warning Rate limit exceeded@ausias-armesto has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 3 minutes and 55 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
📝 Walkthrough## Walkthrough
This update removes the peer version and public status fields from the peer data model, database schema, and all related logic, including REST API endpoints and peer selection strategies. It also updates several dependencies, enhances tracing instrumentation, adjusts probe configuration defaults, and improves logging consistency across multiple modules. Additionally, it introduces packet capture support with pcap and UDP output, adds a Wireshark Lua dissector for HOPR protocols, refactors serialization of probe messages to manual byte-level encoding, and replaces the `spawn_as_abortable` function with a macro variant for async task management.
## Changes
| Files / Paths | Change Summary |
|-------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|
| db/api/src/peers.rs, db/sql/src/peers.rs, hoprd/rest-api/src/node.rs, hoprd/rest-api/src/peers.rs, logic/strategy/src/promiscuous.rs | Removed all logic and struct fields related to peer version and public status; updated constructors and APIs |
| db/migration/src/m20250701_000028_peers_deprecate_fields.rs, db/migration/src/lib.rs | Added migration to remove `Public` and `Version` columns from `NetworkPeer` table for SQLite and Postgres |
| db/sql/src/db.rs | Updated tests to remove references to deprecated peer fields |
| Cargo.toml, logic/strategy/Cargo.toml | Updated dependencies: `libp2p`, `libp2p-identity`, `libp2p-stream`; removed `semver` from strategy crate |
| transport/network/src/network.rs, transport/api/src/network_notifier.rs | Removed peer version from network update logic; simplified method signatures; improved tracing |
| transport/p2p/src/behavior/discovery.rs, transport/p2p/src/swarm.rs | Improved logging and tracing; renamed internal variables; enhanced error context |
| transport/protocol/src/codec.rs, transport/protocol/src/processor.rs, transport/protocol/src/lib.rs, transport/protocol/src/stream.rs | Enhanced tracing instrumentation and logging; minor refactors for clarity |
| transport/probe/src/probe.rs, transport/probe/src/db_proxy.rs, transport/probe/src/config.rs | Improved probe emission delay, logging, and made probe interval public; updated default timeouts |
| hoprd/hoprd/example_cfg.yaml, sdk/barebone.cfg.yaml, sdk/barebone-lower-win-prob.cfg.yaml, sdk/default.cfg.yaml | Adjusted probe timeout and interval defaults in configuration files |
| db/api/src/protocol.rs | Added custom `Debug` implementation for `OutgoingPacket` |
| db/sql/src/protocol.rs | Added tracing instrumentation to async database methods |
| transport/api/src/lib.rs | Added event-driven network update mechanism from discovery events |
| transport/network/Cargo.toml | Added `hopr-crypto-random` dependency |
| db/sql/Cargo.toml | Added `hopr-async-runtime` with Tokio feature to dev dependencies |
| chain/rpc/src/lib.rs, chain/rpc/src/transport.rs | Added conditional compilation for `ReqwestClient` based on `runtime-tokio` feature |
| misc/platform/src/time.rs | Added public re-export of `current_time` function |
| transport/network/src/config.rs | Added constant for dial failure penalty duration |
| transport/p2p/src/lib.rs | Added public re-export of discovery event type |
| transport/probe/src/content.rs | Replaced serialization with manual byte-level encoding/decoding for probe messages and telemetry |
| transport/protocol/src/capture.rs | Added packet capture module with pcap and UDP output support |
| transport/protocol/src/lib.rs | Added packet capture integration and enhanced logging for message protocol |
| transport/protocol/hopr.lua | Added Wireshark Lua dissector for HOPR protocol stack |
| common/async-runtime/src/lib.rs | Replaced `spawn_as_abortable` function with macro version |
| Multiple files (hoprd/hoprd/src/main.rs, hoprd/rest-api/src/session.rs, transport/session/src/manager.rs, hopr/hopr-lib/src/lib.rs, hopr/hopr-lib/tests/chain_integration_tests.rs, chain/api/src/lib.rs, chain/indexer/src/block.rs, transport/api/src/lib.rs) | Changed calls from `spawn_as_abortable` function to macro invocation `spawn_as_abortable!` |
| .github/workflows/build-docker.yaml, flake.nix | Added profile build support with capture feature enabled in CI/CD and Nix packaging |
| transport/probe/Cargo.toml, transport/protocol/Cargo.toml, hopr/hopr-lib/Cargo.toml, hoprd/hoprd/Cargo.toml, transport/api/Cargo.toml, transport/network/Cargo.toml, db/api/Cargo.toml, db/sql/Cargo.toml, chain/rpc/src/lib.rs, chain/rpc/src/transport.rs | Added new optional features and dependencies for packet capture and async runtime |
| transport/mixer/src/channel.rs | Added `Clone` trait to `SenderError` enum |
## Sequence Diagram(s)
```mermaid
sequenceDiagram
participant Client
participant REST_API
participant DB
participant Network
Client->>REST_API: GET /peers
REST_API->>DB: Query PeerStatus (no version/public fields)
DB-->>REST_API: PeerStatus list (without version/public)
REST_API-->>Client: PeerInfo list (without reported_version)
Client->>REST_API: POST /peers/ping
REST_API->>Network: Ping peer
Network-->>REST_API: Ping result (no version)
REST_API-->>Client: PingResponse (latency only) Assessment against linked issues
Assessment against linked issues: Out-of-scope changes
Possibly related PRs
Suggested labels
Suggested reviewers
|
ca5852d
to
7350fbf
Compare
There was a problem hiding this comment.
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 addresses issues with sending messages in the hopr-lib by fixing the error handling in data conversion and improving logging.
- Update error handling logic when converting data to a Message
- Enhance error details by including the original error explanation in the log message
Comments suppressed due to low confidence (1)
transport/probe/src/probe.rs:232
- [nitpick] Using .context() can automatically preserve the original error chain and may simplify error handling. Consider reverting to .context() if maintaining the error chain provenance is desired.
let message: anyhow::Result<Message> = data.try_into().map_err(|e| anyhow::anyhow!("failed to convert data into message: {e}"));
7350fbf
to
7359405
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
transport/probe/src/probe.rs (1)
232-232
: The error handling change looks correct, but check for unused imports.The explicit error mapping approach is functionally equivalent to using
.context()
and properly includes the original error details in the formatted message.Consider checking if the
anyhow::Context
import on line 3 is now unused since you're no longer using the.context()
method:-use anyhow::Context;
If it's still used elsewhere in the file, this change isn't needed.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
transport/probe/src/probe.rs
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (11)
- GitHub Check: hoprd / docker
- GitHub Check: hopli / docker
- GitHub Check: Docs / Rust docs
- GitHub Check: zizmor
- GitHub Check: Linter
- GitHub Check: Build Candidate Binaries (hoprd)
- GitHub Check: Build Candidate Binaries (hopli)
- GitHub Check: tests-smart-contracts
- GitHub Check: tests-unit
- GitHub Check: tests-unit-nightly
- GitHub Check: Cargo Audit
🔇 Additional comments (1)
transport/probe/src/probe.rs (1)
232-232
: Verify consistency with project's error handling patterns.The change from
.context()
to explicit.map_err()
with formatted messages might indicate a broader refactoring effort to standardize error handling approaches across the codebase.#!/bin/bash # Description: Check for consistency in error handling patterns across the codebase # Expected: Find usage patterns of .context() vs .map_err() with anyhow::anyhow! echo "=== Checking usage of .context() method ===" rg "\.context\(" --type rust -A 2 -B 2 echo -e "\n=== Checking usage of .map_err with anyhow::anyhow! ===" rg "\.map_err.*anyhow::anyhow!" --type rust -A 2 -B 2 echo -e "\n=== Checking anyhow::Context imports ===" rg "use.*anyhow::Context" --type rust
c6a52c2
to
727b6a7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
hopr/hopr-lib/src/lib.rs (1)
720-726
: Fix variable name inconsistency.The code references
indexer_peer_update_tx_2
on line 723, but the variable declared above isindexer_peer_update_tx
. This will cause a compilation error.Apply this fix:
spawn(async move { indexer_event_pipeline .map(Ok) - .forward(indexer_peer_update_tx_2) + .forward(indexer_peer_update_tx) .await .expect("The index to transport event chain failed"); });
🧹 Nitpick comments (1)
hopr/hopr-lib/src/lib.rs (1)
684-719
: Consider alignment with PR objectives.While this synchronization timing improvement is beneficial, the PR is titled "improve logging for issues with sending messages" but this change doesn't appear to add any logging improvements. Consider whether additional logging should be added to this synchronization process to help diagnose message sending issues.
For example, you could add logging like:
info!("Syncing peer announcements and network registry updates from previous runs"); let accounts = self.db.get_accounts(None, true).await?; + debug!(account_count = accounts.len(), "Retrieved accounts for synchronization"); for account in accounts.into_iter() {
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
hopr/hopr-lib/src/lib.rs
(1 hunks)transport/p2p/src/behavior/discovery.rs
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (10)
- GitHub Check: hoprd / docker
- GitHub Check: hopli / docker
- GitHub Check: Docs / Rust docs
- GitHub Check: Linter
- GitHub Check: tests-unit-nightly
- GitHub Check: Build Candidate Binaries (hoprd)
- GitHub Check: tests-smart-contracts
- GitHub Check: tests-unit
- GitHub Check: Build Candidate Binaries (hopli)
- GitHub Check: zizmor
🔇 Additional comments (2)
transport/p2p/src/behavior/discovery.rs (1)
208-213
: LGTM! Good security improvement.The conditional check restricts dialing to only allowed peers, which enhances security by preventing connections to unauthorized nodes. The early dialing logic is well-documented and helps ensure heartbeat mechanisms work effectively.
hopr/hopr-lib/src/lib.rs (1)
684-719
: LGTM! Excellent timing improvement.Moving the peer synchronization earlier ensures that pre-existing peer data is properly populated into the transport mechanism before event processing begins. This should prevent race conditions and improve the reliability of peer discovery and network registry state management.
b302a45
to
fa63ba5
Compare
dfbe1eb
to
a224032
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
transport/protocol/src/codec.rs (1)
28-32
: Consider removing redundant manual trace call.With the comprehensive instrumentation now in place on line 20, this manual trace call might be redundant. The instrumentation already captures method entry, parameters, return values, and errors. However, this specific trace provides context about why decoding was skipped, which might be valuable to retain.
If you want to keep the specific context, consider this approach:
- tracing::trace!( - available_bytes = len, - protocol = "msg", - "Skipping decoding operation, insufficient bytes available" - ); + tracing::trace!("Insufficient bytes for decoding: need {SIZE}, have {len}");
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
db/api/src/protocol.rs
(1 hunks)transport/probe/src/probe.rs
(2 hunks)transport/protocol/src/codec.rs
(2 hunks)transport/protocol/src/processor.rs
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- db/api/src/protocol.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- transport/probe/src/probe.rs
⏰ Context from checks skipped due to timeout of 90000ms (10)
- GitHub Check: tests-unit-nightly
- GitHub Check: Build Candidate Binaries (hopli)
- GitHub Check: Build Candidate Binaries (hoprd)
- GitHub Check: tests-unit
- GitHub Check: hoprd / docker
- GitHub Check: hopli / docker
- GitHub Check: Docs / Rust docs
- GitHub Check: Linter
- GitHub Check: zizmor
- GitHub Check: Cargo Audit
🔇 Additional comments (3)
transport/protocol/src/processor.rs (1)
53-53
: Excellent tracing enhancement for improved observability.The addition of
ret(Debug)
anderr
parameters to the existing tracing instrumentation will provide valuable debugging information for connectability issues without impacting the method's core functionality.transport/protocol/src/codec.rs (2)
9-9
: Comprehensive tracing instrumentation enhances debugging capabilities.The detailed instrumentation with custom span naming, field recording, and automatic return/error logging will significantly improve observability for codec operations.
20-20
: Well-structured tracing instrumentation for decode operations.The instrumentation provides excellent context with size and protocol fields, plus automatic return value and error logging.
🍺 🍺 🍺 well deserved. Kudos my friend! |
…d-code-quality' into kauki/v3/logs/improve-logging-and-code-quality
This pull request introduces several changes across multiple modules, focusing on dependency updates, feature enhancements, and database schema modifications. The most significant updates include upgrading the
libp2p
dependencies, adding conditional compilation for Tokio runtime support, deprecating and replacing fields in thePeerStatus
struct, and introducing a new database migration to handle these schema changes.Dependency Updates:
libp2p
to version0.56.0
,libp2p-identity
to0.2.12
, andlibp2p-stream
to0.4.0-alpha
inCargo.toml
. These updates ensure compatibility with the latest features and bug fixes.Feature Enhancements:
runtime-tokio
feature inchain/rpc/src/lib.rs
andchain/rpc/src/transport.rs
. This includes the use ofReqwestClient
and additional tracing capabilities. [1] [2] [3]Database Schema Changes:
is_public
,ignored
, andpeer_version
fields in thePeerStatus
struct with a newignored_until
field to better represent peer ignore periods. Updated related logic and tests accordingly. [1] [2] [3]m20250701_000028_peers_deprecate_fields
) to handle schema changes for both SQLite and Postgres. This includes dropping deprecated fields and adding the newignored_until
field. [1] [2] [3]Codebase Improvements:
Debug
trait for theOutgoingPacket
struct to improve debugging output.Additional Dependency Additions:
hopr-platform
andhopr-async-runtime
dependencies to support new runtime features and time utilities. [1] [2]Closes #7288
Clsoes #7253