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

Default power balance snapshot #1732

Merged
merged 1 commit into from
Jan 18, 2025

Conversation

aminlatifi
Copy link
Member

@aminlatifi aminlatifi commented Jul 29, 2024

Set default zero for power balance snapshot on no return from balance aggregator
Ref #1655

Summary by CodeRabbit

  • New Features

    • Introduced functionality to manage excluded addresses for balance calculations, allowing dynamic exclusion during queries.
  • Bug Fixes

    • Enhanced test coverage to ensure that users excluded from the balance aggregator correctly receive zero snapshot balances.
  • Refactor

    • Improved address management in balance processing by utilizing a Set to ensure unique wallet addresses and enhance efficiency.

Copy link
Contributor

coderabbitai bot commented Jul 29, 2024

Walkthrough

The recent changes enhance the GivPowerBalanceAggregatorAdapterMock and the fillSnapshotBalances functionality by adding address exclusion capabilities and improving balance processing. Excluded addresses are now effectively managed, ensuring they do not affect balance calculations. Additionally, the handling of wallet addresses during snapshot balance filling has been optimized to account for cases where no balance is returned, allowing for zero balances to be recorded appropriately.

Changes

File Change Summary
src/adapters/givPowerBalanceAggregator/givPowerBalanceAggregatorAdapterMock.ts Introduced excludedAddresses Set for ignoring specific addresses, added addExcludedAddresses and clearExcludedAddresses methods, modified getAddressesBalance to filter excluded addresses.
src/services/cronJobs/fillSnapshotBalances.test.ts Added tests for handling zero balances when addresses are excluded from the aggregator; reset excluded addresses after each test.
src/services/cronJobs/fillSnapshotBalances.ts Updated processFillPowerSnapshotJobs to use a Set for unique wallet addresses, ensuring zero balances are filled for addresses without returned balances.

Possibly related issues

Poem

🐰 In fields so wide, we hop with cheer,
Excluded addresses, we hold dear.
With balances zero, all fair and bright,
Our snapshots gleam in the soft moonlight.
Let's celebrate changes, both swift and wise,
For rabbits and balances, we reach for the skies! 🥕✨


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 27eed6f and ff8c26b.

Files selected for processing (3)
  • src/adapters/givPowerBalanceAggregator/givPowerBalanceAggregatorAdapterMock.ts (2 hunks)
  • src/services/cronJobs/fillSnapshotBalances.test.ts (4 hunks)
  • src/services/cronJobs/fillSnapshotBalances.ts (1 hunks)
Additional comments not posted (9)
src/adapters/givPowerBalanceAggregator/givPowerBalanceAggregatorAdapterMock.ts (4)

13-13: Good use of a Set for excluded addresses.

The use of a Set for excludedAddresses is appropriate for efficient lookups and ensuring uniqueness.


15-19: Efficiently adding excluded addresses.

The addExcludedAddresses method efficiently adds multiple addresses to the excludedAddresses set.


21-23: Clear method for resetting excluded addresses.

The clearExcludedAddresses method provides a straightforward way to reset the excludedAddresses set.


36-38: Correctly filtering out excluded addresses.

The getAddressesBalance method correctly filters out addresses that are present in the excludedAddresses set.

src/services/cronJobs/fillSnapshotBalances.ts (3)

123-125: Efficient use of Set for unique wallet addresses.

The use of a Set for addressesToFetch ensures that duplicate addresses are eliminated efficiently.


136-141: Correctly handling processed addresses.

The logic for removing processed addresses from the addressesToFetch set ensures accurate tracking of which addresses have been processed.


149-158: Properly filling zero balances for missing addresses.

The logic for filling zero balances for addresses that were not represented in the fetched balances ensures that all wallet addresses are accounted for.

src/services/cronJobs/fillSnapshotBalances.test.ts (2)

40-40: Ensure excluded addresses are reset after each test.

The mockPowerBalanceAggregator.clearExcludedAddresses() call in the afterEach hook ensures that any excluded addresses are reset after each test.


305-395: Thorough test case for users with no balance on the balance aggregator.

The new test case thoroughly verifies the behavior of the system when users have no balance on the balance aggregator. It ensures that zero balances are correctly filled for excluded users.


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
Collaborator

@mohammadranjbarz mohammadranjbarz left a comment

Choose a reason for hiding this comment

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

Thanks @aminlatifi LGTM

@aminlatifi
Copy link
Member Author

@mohammadranjbarz I see it's not merged yet. Feel free to merge it yourself when you think is appropriate

@mohammadranjbarz
Copy link
Collaborator

@CarlosQ96 As I dot work on impact-graph much, can you take care of it

@mohammadranjbarz I see it's not merged yet. Feel free to merge it yourself when you think is appropriate

@aminlatifi aminlatifi merged commit e4f6b26 into staging Jan 18, 2025
5 checks passed
@aminlatifi aminlatifi deleted the fix/balance-aggregator-fetch-zero-default branch January 18, 2025 12:00
CarlosQ96 added a commit that referenced this pull request Jan 27, 2025
* throw error on un-vouching the givbackseligible projects

* update message

* optimize the approveMultipleProjects

* make projects verified if they become givbacksEligible

* prevent approve or reject draft projects

* fix records

* fix conditions

* use redirectUrl

* fix tests

* add unverifyProjectsTestCases

* add test:projectVerificationTab

* temporary comment

* fix typo

* send email when project verification status changed

* Feat/Generating public user data

* added tests for querying user basic data

* add includeUnlisted to FilterProjectQueryInputParams

* return proper projects

* add recipient address to streams when nonexistent (#1890)

* started endaoment update feature

* Superfluid Base Support (#1893)

* finish project endpoint for superfluid to read

* add filters for network and tokens for recurringdonations

* fix verification logic and emails for base network streams

* Update src/resolvers/recurringDonationResolver.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* comment network test and add cbBTC to seeds

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* remove project validation from anchor contract

* Add networkId logic to superfluid subgraphs (#1896)

* add networkId logic to superfluid subgraphs

* remove networkId from api call to superfluid

* fix eslint

* fix linkedin scope

* fix user info link to user info

* cron job for sitemap generating

* adding additional projects to Endaoment list

* started cronjob

* finished cron job

* Feature cluster matching (#1862)

* add cluster matching entity

* add cluster matching adapters

* finish cocm adapter

* improve error handling for cluster matching

* comment broken contract tests by missing eth_getCode Method

* add feedback to handle qf cases

* add cluster matching job to bootstrap file

* fix coderabbit feedback PR

* termine worker if an exception is raised

* fix updateUser condition to handle email undefined case

* fixed one variable; added cronjob env suggested by Carlos

* removed redundant code

* check config value

* fix calling env variable

* fix/removing endaomentId from update

* add qfStrategy to qfRounds (#1903)

* update bootstrap.js adding check endaoment

* adding sitemap cronjob to bootstrap

* additional logger data

* fine tuninnig log

* improve logger

* fixing endaoment id

* Set default zero for power balance snapshot on no return from balance aggregator (#1732)

Ref #1655

* Fix/Sitemap env variables

* fix missing prefix for url

* fix matching cap calculation

* fix data insertion for cluster matching

* add user passport score null case to clustermatching queries

* fix error handling in cocm adapter

* add cluster matching sync timestamp and logs (#1913)

* add cluster matching sync timestamp and logs

* add nullability to clustermathicng syncAT

* fix db call in worker for cluster matching

* add uniquness constraint to estimatedclustedMatching

* handle undefined case for instant power boosting services

* better error handling in worker job

* fixing prettier problem

* Disable cluster matching

---------

Co-authored-by: Cherik <Pourcheriki@gmail.com>
Co-authored-by: kkatusic <kkatusic@gmail.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Mitch <67759413+divine-comedian@users.noreply.github.com>
Co-authored-by: Lovel George <36924734+lovelgeorge99@users.noreply.github.com>
Co-authored-by: Amin Latifi <a.latifi.al@gmail.com>
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