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

[IND-500]: Create Aggregate trading rewards roundtable task outline #917

Merged
merged 3 commits into from
Jan 3, 2024

Conversation

Christopher-Li
Copy link
Contributor

Changelist

Create Aggregate trading rewards roundtable task outline

Test Plan

none

Author/Reviewer Checklist

  • If this PR has changes that result in a different app state given the same prior state and transaction list, manually add the state-breaking label.
  • If the PR has breaking postgres changes to the indexer add the indexer-postgres-breaking label.
  • If this PR isn't state-breaking but has changes that modify behavior in PrepareProposal or ProcessProposal, manually add the label proposal-breaking.
  • If this PR is one of many that implement a specific feature, manually label them all feature:[feature-name].
  • If you wish to for mergify-bot to automatically create a PR to backport your change to a release branch, manually add the label backport/[branch-name].
  • Manually add any of the following labels: refactor, chore, bug.

Copy link

linear bot commented Jan 2, 2024

Copy link
Contributor

coderabbitai bot commented Jan 2, 2024

Walkthrough

The recent update introduces a feature for aggregating trading rewards over a given time period. This involves setting up tests for the feature and implementing the core functionality that calculates rewards based on trading data, and then saves the aggregated information. Additionally, new configuration parameters and a conditional loop have been added to control the aggregation process.

Changes

File Change Summary
aggregate-trading-rewards.* Sets up tests for and adds functionality to calculate and store aggregated trading rewards. Also, introduces new configuration parameters and a conditional loop for controlling the aggregation process.

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 with CodeRabbit Bot (@coderabbitai)

  • You can directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • You can tag CodeRabbit on specific lines of code or entire files in the PR by tagging @coderabbitai in a comment. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • You can tag @coderabbitai in a PR comment and ask questions about the PR and the codebase. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid.
    • @coderabbitai read the files in the src/scheduler package and generate README in the markdown format.

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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 5ef9175 and 8fb8655.
Files selected for processing (2)
  • indexer/services/roundtable/tests/tasks/aggregate-trading-rewards.test.ts (1 hunks)
  • indexer/services/roundtable/src/tasks/aggregate-trading-rewards.ts (1 hunks)
Additional comments: 3
indexer/services/roundtable/__tests__/tasks/aggregate-trading-rewards.test.ts (1)
  • 1-4: The import statements are correctly structured and include necessary modules for database operations and test mocks.
indexer/services/roundtable/src/tasks/aggregate-trading-rewards.ts (2)
  • 1-5: Import statements are correctly structured and include necessary types from the database and the luxon library for date-time manipulation.

  • 14-21: The Interval and SortedTradingRewardData interfaces are well-defined and provide a clear structure for the data used in the task.

Comment on lines +6 to +23
describe('aggregate-trading-rewards', () => {
beforeAll(async () => {
await dbHelpers.migrate();
await dbHelpers.clearData();
});

beforeEach(async () => {
await testMocks.seedData();
});

afterEach(async () => {
await dbHelpers.clearData();
jest.resetAllMocks();
});

afterAll(async () => {
await dbHelpers.teardown();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Lifecycle hooks for setting up and tearing down the test environment are well-defined. However, there are no actual test cases defined within the describe block. Ensure that test cases are added to validate the functionality of the aggregate-trading-rewards task.

Comment on lines 23 to 55
export default async function runTask(): Promise<void> {
// TODO(IND-499): Add resetting aggregation data when cache is empty
const interval: Interval | undefined = await getTradingRewardDataToProcessInterval();

const tradingRewardData: TradingRewardFromDatabase[] = await getTradingRewardDataToProcess(interval);
const sortedTradingRewardData: SortedTradingRewardData = sortTradingRewardData(tradingRewardData);
await updateTradingRewardsAggregation(sortedTradingRewardData);
// TODO(IND-499): Update AggregateTradingRewardsProcessedCache
}

async function getTradingRewardDataToProcessInterval(): Promise<Interval> {
const latestBlock: BlockFromDatabase = await BlockTable.getLatest();

// TODO(IND-499): Setup AggregateTradingRewardsProcessedCache for start time and add end time
return {
start: DateTime.fromISO(latestBlock.time),
end: DateTime.fromISO(latestBlock.time),
};
}

async function getTradingRewardDataToProcess(interval: Interval): Promise<TradingRewardFromDatabase[]> {
// TODO: Implement
return [];
}

function sortTradingRewardData(tradingRewardData: TradingRewardFromDatabase[]): SortedTradingRewardData {
// TODO: Implement
return {};
}

async function updateTradingRewardsAggregation(sortedTradingRewardData: SortedTradingRewardData): Promise<void> {
// TODO: Implement
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The runTask function and related helper functions contain several TODO comments indicating that the implementation is not yet complete. It is crucial to implement these functions and remove the TODO comments before merging the PR to ensure the task is functional.

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 8fb8655 and a38b2eb.
Files selected for processing (2)
  • indexer/services/roundtable/tests/tasks/aggregate-trading-rewards.test.ts (1 hunks)
  • indexer/services/roundtable/src/tasks/aggregate-trading-rewards.ts (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • indexer/services/roundtable/tests/tasks/aggregate-trading-rewards.test.ts
  • indexer/services/roundtable/src/tasks/aggregate-trading-rewards.ts

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between a38b2eb and 8da9474.
Files selected for processing (3)
  • indexer/services/roundtable/tests/tasks/aggregate-trading-rewards.test.ts (1 hunks)
  • indexer/services/roundtable/src/config.ts (2 hunks)
  • indexer/services/roundtable/src/index.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • indexer/services/roundtable/tests/tasks/aggregate-trading-rewards.test.ts
Additional comments: 4
indexer/services/roundtable/src/index.ts (2)
  • 11-11: The import of aggregateTradingRewardsTasks is consistent with the existing module import pattern.

  • 125-131: Ensure that the configuration parameter LOOPS_ENABLED_AGGREGATE_TRADING_REWARDS is set correctly in all environments to avoid unintended behavior.

indexer/services/roundtable/src/config.ts (2)
  • 45-45: The addition of the LOOPS_ENABLED_AGGREGATE_TRADING_REWARDS configuration parameter with a default value of true is consistent with the pattern of feature flags in the config.

  • 78-80: The addition of the LOOPS_INTERVAL_MS_AGGREGATE_TRADING_REWARDS configuration parameter with a default value of ONE_MINUTE_IN_MILLISECONDS is consistent with the pattern of loop interval settings in the config.

@Christopher-Li Christopher-Li merged commit 3e2c518 into main Jan 3, 2024
11 checks passed
@Christopher-Li Christopher-Li deleted the cl_aggregate_trading_rewards_outline branch January 3, 2024 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

4 participants