Skip to content
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

exit app target column #665

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

exit app target column #665

wants to merge 3 commits into from

Conversation

esterlus
Copy link
Member

@esterlus esterlus commented Oct 29, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a new field exit_app_target in the registered nodes, enhancing data tracking capabilities.
    • Renamed the field exit_node_pub_key to exit_app_pub_key for improved clarity.
  • Bug Fixes

    • Adjusted test setups to reflect the new database schema, ensuring accurate data insertion for tests.
  • Documentation

    • Updated types and structures related to exit nodes for better alignment with the new database schema.

@esterlus esterlus requested a review from mjadach-iv October 29, 2024 10:09
Copy link

coderabbitai bot commented Oct 29, 2024

📝 Walkthrough

Walkthrough

The pull request introduces modifications to the database schema, specifically the registered_nodes table, which now includes a new field exit_app_target and renames the existing field exit_node_pub_key to exit_app_pub_key. Additionally, a newline has been added to the end of the webhook_logs table definition. Corresponding migration scripts and updates to the node module's types and test setups have been implemented to reflect these changes.

Changes

File Change Summary
apps/discovery-platform/db.schema Renamed exit_node_pub_key to exit_app_pub_key, added exit_app_target, and added a newline in webhook_logs.
apps/discovery-platform/migrations/1730194865328_add-exit-app-target.js Added exit_app_target column and renamed exit_node_pub_key to exit_app_pub_key in migration script.
apps/discovery-platform/src/node.spec.ts Updated SQL insert statements to include exit_app_pub_key and exit_app_target.
apps/discovery-platform/src/node.ts Updated ExitNode and DBExitNode types to include target and exit_app_target, and renamed exit_node_pub_key.

Possibly related PRs


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

Copy link

@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

🧹 Outside diff range and nitpick comments (1)
apps/discovery-platform/src/node.spec.ts (1)

Line range hint 82-117: Consider adding specific tests for exit_app_target functionality

The current test suite focuses on pairing functionality but doesn't explicitly verify how the new exit_app_target field affects the node selection or routing behavior. Consider adding test cases that:

  • Verify the application correctly uses the exit_app_target value
  • Test edge cases in target resolution
  • Ensure backward compatibility with existing nodes

Would you like me to help draft additional test cases for these scenarios?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e58f34d and d1b6341.

📒 Files selected for processing (4)
  • apps/discovery-platform/db.schema (2 hunks)
  • apps/discovery-platform/migrations/1730194865328_add-exit-app-target.js (1 hunks)
  • apps/discovery-platform/src/node.spec.ts (1 hunks)
  • apps/discovery-platform/src/node.ts (4 hunks)
🔇 Additional comments (10)
apps/discovery-platform/migrations/1730194865328_add-exit-app-target.js (4)

10-13: LGTM! Down migration correctly reverts changes.

The down migration properly reverses the changes in the correct order:

  1. Renames the column back
  2. Drops the new column

This ensures a clean rollback if needed.


1-13: Consider adding indexes for performance.

Since this appears to be a key field used for lookups (based on the naming), consider adding an index on the exit_app_pub_key column if it doesn't already exist.

#!/bin/bash
# Check for existing indexes on the table
psql \
  -c "SELECT
        t.relname AS table_name,
        i.relname AS index_name,
        a.attname AS column_name
      FROM
        pg_class t,
        pg_class i,
        pg_index ix,
        pg_attribute a
      WHERE
        t.oid = ix.indrelid
        AND i.oid = ix.indexrelid
        AND a.attrelid = t.oid
        AND a.attnum = ANY(ix.indkey)
        AND t.relkind = 'r'
        AND t.relname = 'registered_nodes';"

7-7: Verify no foreign key constraints on the renamed column.

The column rename operation looks correct. However, we should verify there are no foreign key constraints referencing this column that might need to be updated.

#!/bin/bash
# Check for foreign key constraints referencing the exit_node_pub_key column
psql \
  -c "SELECT
        tc.table_schema, 
        tc.constraint_name, 
        tc.table_name, 
        kcu.column_name 
      FROM 
        information_schema.table_constraints AS tc 
        JOIN information_schema.key_column_usage AS kcu
          ON tc.constraint_name = kcu.constraint_name
          AND tc.table_schema = kcu.table_schema
      WHERE tc.constraint_type = 'FOREIGN KEY'
        AND kcu.column_name = 'exit_node_pub_key';"

4-7: Consider adding NOT NULL constraint with a default value.

The new exit_app_target column is added without any constraints. For existing rows, this will be NULL. Consider whether this column should have a NOT NULL constraint with a default value to maintain data integrity.

apps/discovery-platform/db.schema (1)

202-202: LGTM: Added newline at end of file.

This is a good practice to ensure proper file formatting.

apps/discovery-platform/src/node.spec.ts (1)

25-29: Verify the format of exit_app_target test data

The test data uses a consistent pattern of pubtargetN:1234 for the new exit_app_target column. While this covers the basic case, consider adding test cases with:

  • Different port numbers to verify port handling
  • Invalid formats to ensure proper validation
  • Edge cases like missing ports or malformed targets

Let's verify the expected format by checking the schema and related code:

apps/discovery-platform/src/node.ts (4)

19-19: LGTM: ExitNode type extension

The addition of the target field to the ExitNode type properly reflects the schema changes.


36-37: LGTM: DBExitNode type updates

The type changes correctly mirror the database schema modifications, maintaining proper naming conventions.


67-67: LGTM: Updated query columns

The SQL query has been properly updated to select the renamed and new columns while maintaining security practices.


123-124: LGTM: Updated field mapping

The mapping function correctly transforms the database fields to their corresponding API type properties.

apps/discovery-platform/db.schema Show resolved Hide resolved
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