Skip to content

Conversation

Teebor-Choka
Copy link
Contributor

@Teebor-Choka Teebor-Choka commented Jul 8, 2024

Updates to the websocket handling and rest-api:

  • Add explicit reserved tag limit
  • Explicitly handle client closed connections

@Teebor-Choka Teebor-Choka added this to the 2.1.3 milestone Jul 8, 2024
@Teebor-Choka Teebor-Choka requested review from esterlus and a team July 8, 2024 12:01
@Teebor-Choka Teebor-Choka self-assigned this Jul 8, 2024
Copy link
Contributor

coderabbitai bot commented Jul 8, 2024

Walkthrough

Walkthrough

The recent changes introduce a new constant RESERVED_TAG_UPPER_LIMIT to the hopr-lib and transport/api libraries, refine the State struct and various functions within the hoprd/rest-api, and enhance validation and error handling for API functions. These updates aim to improve code clarity, ensure proper handling of reserved tags, and enhance API robustness.

Changes

Files Change Summary
hopr/hopr-lib/src/lib.rs Added RESERVED_TAG_UPPER_LIMIT to the public exports in the core_transport module.
hoprd/rest-api/src/lib.rs Updated State struct, simplified run_hopr_api, enhanced WebSocket handling, improved error handling, and adjusted logging.
transport/api/src/constants.rs Added RESERVED_TAG_UPPER_LIMIT.
transport/api/src/lib.rs Added validation for application_tag in half_key_challenge function utilizing RESERVED_TAG_UPPER_LIMIT.
sequenceDiagram
    participant Client
    participant API
    participant Transport
    participant Constants

    Client->>API: Request `half_key_challenge` with application_tag
    API->>Constants: Retrieve `RESERVED_TAG_UPPER_LIMIT`
    Constants-->>API: RESERVED_TAG_UPPER_LIMIT = 1024
    API->>Transport: Validate application_tag against RESERVED_TAG_UPPER_LIMIT
    alt application_tag valid
        Transport-->>API: Valid application_tag
        API-->>Client: Success response
    else application_tag invalid
        Transport-->>API: Error - InvalidApplicationTag
        API-->>Client: Error response
    end
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Teebor-Choka Teebor-Choka changed the base branch from master to release/saint-louis July 8, 2024 12:01
@Teebor-Choka Teebor-Choka force-pushed the kauki/bug/add-ping-pong-to-websocket branch from 2b63f4d to e287ea8 Compare July 8, 2024 12:02
@Teebor-Choka Teebor-Choka force-pushed the kauki/bug/add-ping-pong-to-websocket branch from e287ea8 to 1ff034c Compare July 8, 2024 12:03
@github-actions github-actions bot removed the dependencies Pull requests that update a dependency file label Jul 8, 2024
@Teebor-Choka Teebor-Choka changed the title Add explicit pong to websocket Update the websocket operations Jul 8, 2024
@Teebor-Choka Teebor-Choka marked this pull request as ready for review July 8, 2024 12:05
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 0d3dd41 and 1ff034c.

Files selected for processing (4)
  • hopr/hopr-lib/src/lib.rs (1 hunks)
  • hoprd/rest-api/src/lib.rs (29 hunks)
  • transport/api/src/constants.rs (1 hunks)
  • transport/api/src/lib.rs (2 hunks)
Additional context used
Learnings (2)
transport/api/src/constants.rs (1)
Learnt from: Teebor-Choka
PR: hoprnet/hoprnet#6299
File: tests/conftest.py:30-30
Timestamp: 2024-05-28T09:19:49.284Z
Learning: The `RESERVED_TAG_UPPER_BOUND` in `tests/conftest.py` is intentionally set to 1023 to test the highest usable value, while the implementation in `transport/api/src/constants.rs` sets it to 1024 as a limit value.
hopr/hopr-lib/src/lib.rs (1)
Learnt from: Teebor-Choka
PR: hoprnet/hoprnet#6299
File: tests/conftest.py:30-30
Timestamp: 2024-05-28T09:19:49.284Z
Learning: The `RESERVED_TAG_UPPER_BOUND` in `tests/conftest.py` is intentionally set to 1023 to test the highest usable value, while the implementation in `transport/api/src/constants.rs` sets it to 1024 as a limit value.
Additional comments not posted (13)
hopr/hopr-lib/src/lib.rs (1)

32-32: LGTM!

The addition of RESERVED_TAG_UPPER_LIMIT to the public exports is correctly done.

hoprd/rest-api/src/lib.rs (12)

27-27: Good addition of trace level logging.

Adding trace level logging enhances the granularity of the logs, which can be very useful for debugging and monitoring.


63-64: Simplified State struct.

The removal of the config field simplifies the State struct, which can reduce complexity. Ensure that the config field is not required elsewhere in the codebase.


248-252: Updated serve_swagger function signature.

The function signature change aligns with the new State struct definition. Ensure that all calls to this function are updated accordingly.


283-283: Simplified run_hopr_api function.

The function has been simplified by eliminating the config initialization. Ensure that the config is not needed in the function.


379-383: Good addition of debug logging for WebSocket communication.

Adding debug logging improves traceability of WebSocket communication, which is beneficial for debugging.


403-405: Good cleanup of commented-out code.

Removing commented-out code improves code readability and maintainability.


423-455: Good addition of handling for binary WebSocket messages and logging for unsupported commands.

Adding handling for binary WebSocket messages and logging for unsupported commands improves functionality and traceability.


456-465: Good addition of handling for client-closed connections and ping messages.

Adding handling for client-closed connections and ping messages improves WebSocket functionality and traceability.


512-513: Good addition of InvalidApplicationTag variant to ApiErrorStatus enum.

Adding the InvalidApplicationTag variant improves error handling for invalid application tags.


1463-1465: Necessary imports for new functionality.

Adding import statements for AsUnixTimestamp, HalfKeyChallenge, and RESERVED_TAG_UPPER_LIMIT is necessary for the new functionality related to message handling and validation.


Line range hint 1567-1587: Good addition of input validation for SendMessageBodyRequest.

Adding validation for SendMessageBodyRequest and ensuring either path or hops must be specified improves input validation and error handling.


1738-1742: Good addition of tag validation in delete_messages function.

Adding validation to ensure the tag is above RESERVED_TAG_UPPER_LIMIT improves input validation and error handling.

Copy link
Member

@esterlus esterlus left a comment

Choose a reason for hiding this comment

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

Seems like the websocket library already takes care of heatbeat responses.
Your change will send a duplicate pong response. Please remove manual heatbeat answering.

@Teebor-Choka Teebor-Choka force-pushed the kauki/bug/add-ping-pong-to-websocket branch from 1ff034c to f7312ec Compare July 10, 2024 11:58
@github-actions github-actions bot added the dependencies Pull requests that update a dependency file label Jul 10, 2024
@Teebor-Choka Teebor-Choka requested a review from esterlus July 10, 2024 12:01
@Teebor-Choka Teebor-Choka force-pushed the kauki/bug/add-ping-pong-to-websocket branch from f7312ec to 9ed5394 Compare July 10, 2024 12:02
@github-actions github-actions bot removed the dependencies Pull requests that update a dependency file label Jul 10, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 1ff034c and f7312ec.

Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
Files selected for processing (4)
  • hopr/hopr-lib/src/lib.rs (1 hunks)
  • hoprd/rest-api/src/lib.rs (28 hunks)
  • transport/api/src/constants.rs (1 hunks)
  • transport/api/src/lib.rs (2 hunks)
Additional context used
Learnings (1)
transport/api/src/constants.rs (2)
Learnt from: Teebor-Choka
PR: hoprnet/hoprnet#6266
File: hopr/hopr-lib/src/lib.rs:680-682
Timestamp: 2024-05-21T12:52:29.416Z
Learning: The constant `INDEXER_UPDATE_QUEUE_SIZE` is set to `4096` in the codebase.
Learnt from: Teebor-Choka
PR: hoprnet/hoprnet#6299
File: tests/conftest.py:30-30
Timestamp: 2024-05-28T09:19:49.284Z
Learning: The `RESERVED_TAG_UPPER_BOUND` in `tests/conftest.py` is intentionally set to 1023 to test the highest usable value, while the implementation in `transport/api/src/constants.rs` sets it to 1024 as a limit value.
Additional comments not posted (9)
transport/api/src/lib.rs (1)

414-421: Correct the validation logic for application_tag.

The validation logic should check if application_tag is greater than or equal to RESERVED_TAG_UPPER_LIMIT, not less than.

- if application_tag < RESERVED_TAG_UPPER_LIMIT {
+ if application_tag >= RESERVED_TAG_UPPER_LIMIT {

Likely invalid or redundant comment.

hopr/hopr-lib/src/lib.rs (1)

32-32: Ensure consistent export of RESERVED_TAG_UPPER_LIMIT.

The constant RESERVED_TAG_UPPER_LIMIT is correctly added to the public exports. Ensure this is consistent with its usage throughout the codebase.

hoprd/rest-api/src/lib.rs (7)

63-64: Simplified State struct.

The State struct now only contains an Arc<Hopr>. Ensure that all parts of the code that previously relied on the config field are updated accordingly.


248-252: Updated serve_swagger function signature.

The function signature now reflects the changes in the State struct. Ensure that the function works correctly with the updated State.


283-283: Simplified run_hopr_api function.

The function now initializes State without the config field. Ensure that all parts of the code that previously relied on the config field are updated accordingly.


379-383: Enhanced WebSocket message handling.

The WebSocket handling logic now includes better message handling and logging. Ensure that these enhancements work as expected and don't introduce any issues.


423-425: Explicit handling of client-closed connections.

The WebSocket handling now includes explicit handling of client-closed connections. Ensure this change is robust and doesn't introduce issues.


471-472: Added InvalidApplicationTag variant to ApiErrorStatus.

The new variant is correctly added to the enum. Ensure that it is used appropriately in the code.


1422-1424: Adjusted validation rules for path and hops fields.

The validation rules have been adjusted to ensure proper validation of path and hops fields. Ensure these adjustments are correctly implemented and don't introduce any issues.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 1ff034c and 9ed5394.

Files selected for processing (4)
  • hopr/hopr-lib/src/lib.rs (1 hunks)
  • hoprd/rest-api/src/lib.rs (28 hunks)
  • transport/api/src/constants.rs (1 hunks)
  • transport/api/src/lib.rs (2 hunks)
Additional context used
Learnings (1)
transport/api/src/constants.rs (1)
Learnt from: Teebor-Choka
PR: hoprnet/hoprnet#6299
File: tests/conftest.py:30-30
Timestamp: 2024-05-28T09:19:49.284Z
Learning: The `RESERVED_TAG_UPPER_BOUND` in `tests/conftest.py` is intentionally set to 1023 to test the highest usable value, while the implementation in `transport/api/src/constants.rs` sets it to 1024 as a limit value.
Additional comments not posted (17)
transport/api/src/constants.rs (1)

10-14: LGTM!

The constant RESERVED_TAG_UPPER_LIMIT is defined correctly and the comment provides a clear explanation of its purpose.

transport/api/src/lib.rs (2)

52-52: LGTM!

The import of RESERVED_TAG_UPPER_LIMIT is correct.


414-421: Validation logic for application_tag is correct.

The validation logic ensures that the application_tag is not within the reserved range.

hopr/hopr-lib/src/lib.rs (1)

32-32: LGTM!

The constant RESERVED_TAG_UPPER_LIMIT is correctly added to the public exports.

hoprd/rest-api/src/lib.rs (13)

248-252: LGTM! But verify the consistency of the function signature change.

The function signature change aligns with the State struct changes.

However, ensure that all function calls to serve_swagger match the new signature.

Verification successful

Verified: All function calls to serve_swagger match the new signature.

The function serve_swagger is correctly called with the new signature in the relevant file.

  • hoprd/rest-api/src/lib.rs: app.at("/swagger-ui/*").get(serve_swagger);
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `serve_swagger` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type rust 'serve_swagger'

Length of output: 659


1422-1424: LGTM! But verify the usage of the new constant RESERVED_TAG_UPPER_LIMIT.

The introduction of the RESERVED_TAG_UPPER_LIMIT constant is appropriate.

However, ensure that the new constant is used correctly in the code.


1726-1730: Ensure the validation logic is correct.

The validation logic for the size function is appropriate.


1795-1799: Ensure the validation logic is correct.

The validation logic for the pop function is appropriate.


1897-1901: Ensure the validation logic is correct.

The validation logic for the peek function is appropriate.


471-472: LGTM! But verify the usage of the new enum variant.

The addition of the InvalidApplicationTag variant seems appropriate.

However, ensure that the new variant is used correctly in the code.

Verification successful

The new enum variant InvalidApplicationTag is used correctly.

The variant is appropriately integrated into the error handling logic in multiple places within hoprd/rest-api/src/lib.rs.

  • The InvalidApplicationTag is used in response to an invalid tag scenario where the tag is less than the RESERVED_TAG_UPPER_LIMIT.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new enum variant `InvalidApplicationTag`.

# Test: Search for usages of `InvalidApplicationTag` in the code.
rg --type rust 'InvalidApplicationTag'

Length of output: 613


Script:

#!/bin/bash
# Description: Extract surrounding lines of each match of `InvalidApplicationTag` to understand its context.

# Use ripgrep to get lines around each match for context.
rg --type rust 'InvalidApplicationTag' -A 3 -B 3

Length of output: 3190


1464-1467: Ensure the validation rules are correct.

The validation rules for the path and hops fields in the SendMessageBodyRequest struct are appropriate.

Verification successful

Validation rules for SendMessageBodyRequest struct are appropriate.

The validation rules for the path and hops fields in the SendMessageBodyRequest struct are correctly applied and make sense within their usage contexts.

  • The path field is validated with #[validate(length(min = 0, max = 3))], ensuring the vector's length is between 0 and 3.
  • The hops field is validated with #[validate(range(min = 0, max = 3))], ensuring the value is between 0 and 3.

These validations are enforced in the send_message function, where args.validate() is called.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the validation rules for the `path` and `hops` fields.

# Test: Search for usages of `SendMessageBodyRequest` struct.
rg --type rust 'SendMessageBodyRequest'

Length of output: 1017


Script:

#!/bin/bash
# Extract lines around each usage of SendMessageBodyRequest for inspection

# Extract 5 lines before and after each match to provide context
rg --type rust 'SendMessageBodyRequest' -A 5 -B 5

Length of output: 6788


1526-1531: Ensure the error handling is correct.

The error handling for the send_message function has been improved.

Verification successful

Error handling in the send_message function is correct.

The error handling for the send_message function in hoprd/rest-api/src/lib.rs is robust and appropriately uses HTTP status codes and error messages for different failure scenarios.

  • Validation errors and specific condition checks return a 422 response.
  • Errors from the hopr.send_message call are also handled by returning a 422 response with the error details.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the error handling for the `send_message` function.

# Test: Search for usages of `send_message` function.
rg --type rust 'send_message'

Length of output: 6938


Script:

#!/bin/bash
# Locate the implementation of the `send_message` function in `hoprd/rest-api/src/lib.rs` and display its content for analysis.
ast-grep --lang rust --pattern $'pub async fn send_message($_) -> $_ {
  $$$
}' hoprd/rest-api/src/lib.rs

Length of output: 2700


1943-1947: Ensure the validation logic is correct.

The validation logic for the peek_all function is appropriate.

Verification successful

Let's start by extracting the full implementation of the peek_all function and checking the definition of RESERVED_TAG_UPPER_LIMIT.


Validation logic is correct.

The validation logic for the peek_all function in hoprd/rest-api/src/lib.rs correctly ensures that tags below RESERVED_TAG_UPPER_LIMIT (1024) are not used. This is consistent with the intended use of RESERVED_TAG_UPPER_LIMIT.

  • hoprd/rest-api/src/lib.rs lines 1943-1947: The validation logic checks if args.tag is present and less than RESERVED_TAG_UPPER_LIMIT, returning a 400 response if true.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the validation logic for the `peek_all` function.

# Test: Search for usages of `peek_all` function.
rg --type rust 'peek_all'

Length of output: 1402


Script:

#!/bin/bash
# Extracting the full implementation of the `peek_all` function from `hoprd/rest-api/src/lib.rs`
ast-grep --lang rust --pattern 'pub async fn peek_all($_) -> $_ { $$$ }'

# Searching for the definition of `RESERVED_TAG_UPPER_LIMIT` in the codebase
rg 'RESERVED_TAG_UPPER_LIMIT'

Length of output: 3242


283-283: LGTM! But verify the consistency of the function changes.

The function changes align with the State struct changes.

However, ensure that the changes do not impact other parts of the code.

Verification successful

The changes to the run_hopr_api function are consistent and do not negatively impact other parts of the code.

  • host_listen is correctly formatted and passed as a string.
  • cfg.as_redacted_string()? is properly used to get a redacted string representation of the configuration.
  • &cfg.api is passed correctly as a reference to the API configuration.
  • node is correctly initialized and passed as an Arc of hopr_lib::Hopr.
  • inbox.clone() is correctly passed as a cloned Arc of hoprd_inbox::Inbox.
  • ws_events_rx is correctly initialized and passed as a deactivated receiver.
  • Some(msg_encoder) is correctly passed as an optional message encoder.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify if the changes to `run_hopr_api` impact other parts of the code.

# Test: Search for usages of `run_hopr_api` function.
rg --type rust 'run_hopr_api'

Length of output: 185


Script:

#!/bin/bash
# Extract relevant lines of code around the usages of `run_hopr_api` in `hoprd/hoprd/src/main.rs`
rg --type rust -A 10 -B 10 'run_hopr_api' hoprd/hoprd/src/main.rs

Length of output: 1394


Script:

#!/bin/bash
# Extract the definitions of the arguments passed to `run_hopr_api` in `hoprd/hoprd/src/main.rs`
rg --type rust -A 5 -B 5 'let host_listen' hoprd/hoprd/src/main.rs
rg --type rust -A 5 -B 5 'cfg.as_redacted_string' hoprd/hoprd/src/main.rs
rg --type rust -A 5 -B 5 '&cfg.api' hoprd/hoprd/src/main.rs
rg --type rust -A 5 -B 5 'node' hoprd/hoprd/src/main.rs
rg --type rust -A 5 -B 5 'inbox.clone' hoprd/hoprd/src/main.rs
rg --type rust -A 5 -B 5 'ws_events_rx' hoprd/hoprd/src/main.rs
rg --type rust -A 5 -B 5 'Some(msg_encoder)' hoprd/hoprd/src/main.rs

Length of output: 9359


63-64: Verify the impact of removing the config field from State.

The removal of the config field simplifies the State struct, but ensure that other parts of the code that previously accessed config are updated accordingly.


1844-1848: Ensure the validation logic is correct.

The validation logic for the pop_all function is appropriate.

Verification successful

Validation logic for pop_all function is correct.

The validation logic for the tag parameter in the pop_all function is implemented appropriately. Specifically, the check in hoprd/inbox/src/inbox.rs ensures that excluded tags are handled correctly.

  • hoprd/inbox/src/inbox.rs: The is_excluded_tag(&tag) check ensures excluded tags return an empty vector.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the validation logic for the `pop_all` function.

# Test: Search for usages of `pop_all` function.
rg --type rust 'pop_all'

Length of output: 2783


Script:

#!/bin/bash
# Extract the pop_all function definition from hoprd/inbox/src/ring.rs
ast-grep --lang rust --pattern 'async fn pop_all($_) -> $_ { $$$ }' hoprd/inbox/src/ring.rs

# Extract the pop_all function definition from hoprd/inbox/src/inbox.rs
ast-grep --lang rust --pattern 'async fn pop_all($_) -> $_ { $$$ }' hoprd/inbox/src/inbox.rs

Length of output: 188


Script:

#!/bin/bash
# Extract the pop_all function definition from hoprd/inbox/src/ring.rs
ast-grep --lang rust --pattern 'fn pop_all($_) -> $_ { $$$ }' hoprd/inbox/src/ring.rs

# Extract the pop_all function definition from hoprd/inbox/src/inbox.rs
ast-grep --lang rust --pattern 'fn pop_all($_) -> $_ { $$$ }' hoprd/inbox/src/inbox.rs

Length of output: 176


Script:

#!/bin/bash
# Search for the pop_all function definition in hoprd/inbox/src/ring.rs with context lines
rg 'fn pop_all' -A 10 hoprd/inbox/src/ring.rs

# Search for the pop_all function definition in hoprd/inbox/src/inbox.rs with context lines
rg 'fn pop_all' -A 10 hoprd/inbox/src/inbox.rs

Length of output: 1618


1697-1701: Ensure the validation logic is correct.

The validation logic for the delete_messages function is appropriate.

Verification successful

Validation logic is correct.

The validation logic in the delete_messages function appropriately checks if the tag is within the reserved range and returns an error if so. The implementation correctly handles the optional nature of the tag field.

  • TagQueryRequest struct: hoprd/rest-api/src/lib.rs (line 1429)
  • RESERVED_TAG_UPPER_LIMIT defined as 1024: transport/api/src/constants.rs
  • InvalidApplicationTag error variant: hoprd/rest-api/src/lib.rs (line 468)
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the validation logic for the `delete_messages` function.

# Test: Search for usages of `delete_messages` function.
rg --type rust 'delete_messages'

Length of output: 283


Script:

#!/bin/bash
# Extract the full implementation of the `delete_messages` function for detailed analysis.
ast-grep --lang rust --pattern 'pub async fn delete_messages($_) -> $_ {
    $$$
}' --json

Length of output: 1418


Script:

#!/bin/bash
# Extract the definitions of `TagQueryRequest`
ast-grep --lang rust --pattern 'struct TagQueryRequest {
    $$$
}' --json

# Extract the definition of `RESERVED_TAG_UPPER_LIMIT`
rg 'RESERVED_TAG_UPPER_LIMIT'

# Extract the definition of `InvalidApplicationTag`
ast-grep --lang rust --pattern 'enum ApiErrorStatus {
    $$$
}' --json

Length of output: 2718


Script:

#!/bin/bash
# Search for the definition of `TagQueryRequest` in the codebase to ensure the validation logic is complete.
rg 'struct TagQueryRequest'

Length of output: 95


Script:

#!/bin/bash
# Extract the full definition of the `TagQueryRequest` struct from `hoprd/rest-api/src/lib.rs`.
ast-grep --lang rust --pattern 'pub(crate) struct TagQueryRequest {
    $$$
}' --json

Length of output: 667

Copy link
Member

@esterlus esterlus left a comment

Choose a reason for hiding this comment

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

Websocket heartbeat working fine

@Teebor-Choka
Copy link
Contributor Author

Websocket heartbeat working fine

But did it solve your disconnecting issues?

@Teebor-Choka Teebor-Choka merged commit 66dd9f3 into release/saint-louis Jul 10, 2024
@Teebor-Choka Teebor-Choka deleted the kauki/bug/add-ping-pong-to-websocket branch July 10, 2024 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants