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

(OraklNode) Update redis publish key and related codes #2222

Merged
merged 3 commits into from
Aug 26, 2024

Conversation

nick-bisonai
Copy link
Collaborator

@nick-bisonai nick-bisonai commented Aug 24, 2024

Description

It has been revealed that even though DAL was subscribing to multiple nodes, there were data delay when deploying bisonai node. After investigating this issue, it has been found that there were wrong implementation regarding redis pubsub

AS-IS

Publish & Subscription redis key was based on config id

TO-BE

Publish & Subscription base on symbol name

Why is it required?

Config id is not a consistent value among different nodes
Through this update it will properly utilize data from multiple nodes from DAL

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist before requesting a review

  • I have performed a self-review of my code.
  • If it is a core feature, I have added thorough tests.

Deployment

  • Should publish npm package
  • Should publish Docker image

@nick-bisonai nick-bisonai self-assigned this Aug 24, 2024
@nick-bisonai nick-bisonai requested a review from a team as a code owner August 24, 2024 12:42
Copy link
Contributor

coderabbitai bot commented Aug 24, 2024

Walkthrough

Walkthrough

The modifications primarily involve altering function signatures and variable types across multiple files, shifting from integer-based identifiers to string-based names for configuration management. This change impacts how data is processed, published, and tested within the application, ensuring a more direct and descriptive approach to handling configurations and submission data.

Changes

File(s) Change Summary
node/pkg/aggregator/aggregator.go, node/pkg/aggregator/aggregator_test.go Modified PublishGlobalAggregateAndProof function signatures to include a new string parameter, affecting data publication.
node/pkg/aggregator/app.go Changed setGlobalAggregateBulkWriter to use strings instead of integers for configuration names.
node/pkg/aggregator/globalaggregatebulkwriter.go, node/pkg/aggregator/globalaggregatebulkwriter_test.go Updated data structures and functions to utilize string keys for configurations instead of integers.
node/pkg/aggregator/utils.go Adjusted PublishGlobalAggregateAndProof to accept a string name instead of using identifiers for publishing.
node/pkg/common/keys/keys.go Altered SubmissionDataStreamKey function to accept string parameters instead of integers.
node/pkg/dal/collector/collector.go, node/pkg/dal/hub/hub.go Changed OutgoingStream from integer keys to string keys for better clarity in handling outgoing streams.
node/pkg/dal/tests/api_test.go, node/pkg/dal/tests/collector_test.go, node/pkg/dal/tests/main_test.go, node/pkg/reporter/app_test.go Updated test functions to reflect changes in parameters for published data, shifting to static string identifiers.

Sequence Diagram(s)

sequenceDiagram
    participant Aggregator
    participant Publisher
    participant Database

    Aggregator->>Publisher: PublishGlobalAggregateAndProof(name, globalAggregate, proof)
    Publisher->>Database: db.Publish(name, globalAggregate, proof)
    Database-->>Publisher: Acknowledgment
    Publisher-->>Aggregator: Result
Loading

🐰 In the meadow where changes bloom,
A hop of joy dispels the gloom.
With strings now guiding every flow,
Our code will dance, and swiftly go!
Let’s celebrate with leaps and bounds,
In rabbit hearts, new joy surrounds! ✨


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 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
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 UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6f0794f and bd5b825.

Files selected for processing (13)
  • node/pkg/aggregator/aggregator.go (1 hunks)
  • node/pkg/aggregator/aggregator_test.go (1 hunks)
  • node/pkg/aggregator/app.go (1 hunks)
  • node/pkg/aggregator/globalaggregatebulkwriter.go (5 hunks)
  • node/pkg/aggregator/globalaggregatebulkwriter_test.go (5 hunks)
  • node/pkg/aggregator/utils.go (1 hunks)
  • node/pkg/common/keys/keys.go (1 hunks)
  • node/pkg/dal/collector/collector.go (4 hunks)
  • node/pkg/dal/hub/hub.go (1 hunks)
  • node/pkg/dal/tests/api_test.go (6 hunks)
  • node/pkg/dal/tests/collector_test.go (1 hunks)
  • node/pkg/dal/tests/main_test.go (1 hunks)
  • node/pkg/reporter/app_test.go (1 hunks)
Additional comments not posted (30)
node/pkg/common/keys/keys.go (1)

3-4: LGTM! Simplified function signature.

The change to use a string parameter directly improves clarity and aligns with the PR objective of using symbol names for Redis keys.

node/pkg/aggregator/utils.go (1)

21-29: LGTM! Enhanced flexibility with the new parameter.

The addition of the name parameter aligns with the PR objective and enhances the flexibility of the function.

Run the following script to verify the function usage:

Verification successful

Function usage verified successfully.

All calls to PublishGlobalAggregateAndProof in the codebase are consistent with the new signature, including the name parameter. No discrepancies were found.

  • node/pkg/aggregator/aggregator.go
  • node/pkg/aggregator/aggregator_test.go
  • node/pkg/aggregator/globalaggregatebulkwriter_test.go
Scripts executed

The following scripts were executed for the analysis:

Script:

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

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'PublishGlobalAggregateAndProof'

Length of output: 2323

node/pkg/reporter/app_test.go (1)

64-64: LGTM! Simplified test with a consistent key.

Using a hardcoded string for the Redis key in the test ensures consistent behavior and simplifies the test logic.

node/pkg/dal/tests/collector_test.go (1)

88-88: Ensure consistency with the new parameter.

The addition of the "test-aggregate" string parameter in the testPublishData function call aligns with the shift from configuration IDs to symbol names. Verify that all related tests and function calls are updated consistently.

node/pkg/aggregator/globalaggregatebulkwriter_test.go (5)

25-25: Update to use configuration names.

The use of WithConfigNames instead of WithConfigIds aligns with the updated approach to use configuration names. This change enhances clarity and consistency with the new design paradigm.


43-43: Update to use configuration names.

The change to WithConfigNames in the TestGlobalAggregateBulkWriterStart function is consistent with the new design approach. Ensure all related tests are updated similarly.


62-62: Update to use configuration names.

The change to WithConfigNames in the TestGlobalAggregateBulkWriterStop function is consistent with the new design approach. Ensure all related tests are updated similarly.


83-83: Update to use configuration names.

The change to WithConfigNames in the TestGlobalAggregateBulkWriterDataStore function is consistent with the new design approach. Ensure all related tests are updated similarly.


112-112: Verify the static string usage.

The use of the static string "test_pair" in the PublishGlobalAggregateAndProof function call may affect the logic of the test. Ensure this change aligns with the intended functionality and that all related tests are updated consistently.

node/pkg/dal/tests/main_test.go (1)

39-40: Update function signature to use symbol names.

The addition of the name parameter in the testPublishData function aligns with the shift from configuration IDs to symbol names. Ensure all calls to this function are updated accordingly.

node/pkg/aggregator/aggregator_test.go (2)

124-124: LGTM! But verify the subscription key change.

The change from node.ID to node.Name for the subscription key is consistent with the PR objectives.

Ensure that this change is reflected wherever SubmissionDataStreamKey is used.


129-129: LGTM! But verify the function signature change.

The addition of "test_pair" to the PublishGlobalAggregateAndProof function call is consistent with the updated function signature.

Ensure that all calls to PublishGlobalAggregateAndProof in the codebase match the new signature.

Run the following script to verify the function signature change:

Verification successful

Function Signature Change Verified

All calls to the PublishGlobalAggregateAndProof function in the codebase match the updated signature, including the name parameter. No discrepancies were found.

Scripts executed

The following scripts were executed for the analysis:

Script:

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

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'PublishGlobalAggregateAndProof'

Length of output: 2323

node/pkg/dal/hub/hub.go (1)

142-142: LGTM! Simplified broadcast channel initialization.

The use of symbol directly as the key in initializeBroadcastChannels simplifies the logic and improves performance.

The removal of configIdToSymbol is appropriate since its functionality is no longer needed.

node/pkg/aggregator/globalaggregatebulkwriter.go (5)

17-17: LGTM! Updated ReceiveChannels to use string keys.

The change from int32 to string for ReceiveChannels keys enhances clarity and aligns with the PR objectives.


33-33: LGTM! Updated ConfigNames in configuration.

The change from ConfigIds to ConfigNames reflects a broader semantic shift and aligns with the PR objectives.


50-52: LGTM! Renamed WithConfigIds to WithConfigNames.

The renaming and parameter change in WithConfigNames align with the updated configuration structure.


66-73: LGTM! Updated NewGlobalAggregateBulkWriter to use string keys.

The initialization of ReceiveChannels with string keys aligns with the updated configuration structure.


105-119: LGTM! Updated receiveEach method to use string keys.

The use of string keys in the receiveEach method aligns with the updated configuration structure.

node/pkg/dal/collector/collector.go (4)

34-34: LGTM: Change to OutgoingStream key type.

The change from int32 to string keys in OutgoingStream aligns with the shift to using symbol names, improving clarity and consistency.


Line range hint 95-110: LGTM: Initialization changes in NewCollector.

The initialization of OutgoingStream with string keys and the update to use config.Name for redisTopics are consistent with the shift to symbol names.


231-236: LGTM: Update in processIncomingData.

The use of result.Symbol for accessing OutgoingStream is consistent with the change to string keys and ensures correct data processing.


Line range hint 279-279: Verify consistency in IncomingDataToOutgoingData.

Ensure that the continued use of int32 keys for Symbols and FeedHashes is intentional and consistent with the overall design.

node/pkg/aggregator/app.go (1)

62-67: LGTM: Transition to configNames in setGlobalAggregateBulkWriter.

The use of configNames instead of configIds aligns with the shift to string-based configuration handling, ensuring consistency with the new data model.

node/pkg/aggregator/aggregator.go (1)

285-285: LGTM: Addition of n.Name in HandleProofMessage.

Including n.Name in the PublishGlobalAggregateAndProof call enhances the specificity of data identification, aligning with the PR objectives.

node/pkg/dal/tests/api_test.go (6)

99-99: Change to use "test-aggregate" is appropriate.

The update aligns with the PR's goal to use symbol names for Redis keys, improving consistency across nodes.


171-171: Change to use "test-aggregate" is appropriate.

This update is consistent with the PR's objective and aligns with the changes in other test cases.


212-212: Change to use "test-aggregate" is appropriate.

This update is consistent with the PR's objective and aligns with the changes in other test cases.


260-260: Change to use "test-aggregate" is appropriate.

This update is consistent with the PR's objective and aligns with the changes in other test cases.


330-330: Change to use "test-aggregate" is appropriate.

This update is consistent with the PR's objective and aligns with the changes in other test cases.


476-476: Change to use "test-aggregate" is appropriate.

This update is consistent with the PR's objective and aligns with the changes in other test cases.

Copy link
Contributor

@Intizar-T Intizar-T left a comment

Choose a reason for hiding this comment

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

lgtm!

@nick-bisonai nick-bisonai force-pushed the feat/fix-invalid-subscription-issue branch from bd5b825 to d0ec476 Compare August 26, 2024 04:01
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 UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bd5b825 and d0ec476.

Files selected for processing (13)
  • node/pkg/aggregator/aggregator.go (1 hunks)
  • node/pkg/aggregator/aggregator_test.go (1 hunks)
  • node/pkg/aggregator/app.go (1 hunks)
  • node/pkg/aggregator/globalaggregatebulkwriter.go (5 hunks)
  • node/pkg/aggregator/globalaggregatebulkwriter_test.go (5 hunks)
  • node/pkg/aggregator/utils.go (1 hunks)
  • node/pkg/common/keys/keys.go (1 hunks)
  • node/pkg/dal/collector/collector.go (4 hunks)
  • node/pkg/dal/hub/hub.go (1 hunks)
  • node/pkg/dal/tests/api_test.go (6 hunks)
  • node/pkg/dal/tests/collector_test.go (1 hunks)
  • node/pkg/dal/tests/main_test.go (1 hunks)
  • node/pkg/reporter/app_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (11)
  • node/pkg/aggregator/aggregator.go
  • node/pkg/aggregator/aggregator_test.go
  • node/pkg/aggregator/app.go
  • node/pkg/aggregator/globalaggregatebulkwriter.go
  • node/pkg/aggregator/globalaggregatebulkwriter_test.go
  • node/pkg/aggregator/utils.go
  • node/pkg/common/keys/keys.go
  • node/pkg/dal/tests/api_test.go
  • node/pkg/dal/tests/collector_test.go
  • node/pkg/dal/tests/main_test.go
  • node/pkg/reporter/app_test.go
Additional comments not posted (2)
node/pkg/dal/hub/hub.go (1)

142-144: LGTM!

The function now directly uses symbol as the key, simplifying the logic and improving performance.

The code changes are approved.

node/pkg/dal/collector/collector.go (1)

34-34: LGTM!

The changes reflect a shift from using int32 identifiers to using string names, improving clarity and aligning with the new data model.

The code changes are approved.

Also applies to: 95-95, 107-110, 113-118, 125-127

@nick-bisonai nick-bisonai merged commit 9d138dc into master Aug 26, 2024
4 checks passed
@nick-bisonai nick-bisonai deleted the feat/fix-invalid-subscription-issue branch August 26, 2024 04:31
@coderabbitai coderabbitai bot mentioned this pull request Sep 28, 2024
8 tasks
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.

2 participants