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

feat(oracle): Add more events on validator's performance #1755

Merged
merged 2 commits into from
Dec 29, 2023

Conversation

matthiasmatt
Copy link
Contributor

@matthiasmatt matthiasmatt commented Dec 29, 2023

Purpose / Abstract

Summary by CodeRabbit

  • New Features

    • Introduced new events for tracking validator performance in the oracle module, including voting power, reward weight, and win/abstain/miss counts.
  • Documentation

    • Updated the CHANGELOG to reflect the addition of validator performance events in the oracle module.

@matthiasmatt matthiasmatt requested a review from a team as a code owner December 29, 2023 10:47
Copy link
Contributor

coderabbitai bot commented Dec 29, 2023

Walkthrough

The recent update introduces new events in the oracle system, specifically tracking validator performance metrics such as wins, misses, abstains, slashes, and rewards. This allows for better monitoring of validator activities and their contributions to consensus and reward mechanisms within the protocol.

Changes

File Path Change Summary
proto/nibiru/oracle/v1/event.proto Added EventValidatorPerformance message with fields for validator metrics.
x/oracle/keeper/update_exchange_rates.go Introduced logic to emit events for each validator's performance metrics.

Assessment against linked issues

Objective Addressed Explanation
Introduce events for validator metrics: wins, misses, abstains, slashes, rewards (#1530) The code changes include the addition of the EventValidatorPerformance and logic to emit these events, addressing the objective.

Poem

In the realm of code, where validators play,
A rabbit hopped through, shedding light on their way.
Metrics in tow, for each validator's stance,
Wins, misses, and rewards, in the blockchain dance. 🐇💻✨

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.

@matthiasmatt matthiasmatt changed the title feat: add more events to the oracle feat(oracle): Add more events on validator's performance Dec 29, 2023
@matthiasmatt matthiasmatt enabled auto-merge (squash) December 29, 2023 10:47
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 9ba0f80 and eb7fdbf.
Files ignored due to filter (1)
  • x/oracle/types/event.pb.go
Files selected for processing (2)
  • proto/nibiru/oracle/v1/event.proto (1 hunks)
  • x/oracle/keeper/update_exchange_rates.go (1 hunks)
Additional comments: 3
proto/nibiru/oracle/v1/event.proto (1)
  • 58-77: The new EventValidatorPerformance message is well-defined with appropriate field names and data types that align with the PR objectives. The use of int64 for counts and weights is suitable for the expected range of values.
x/oracle/keeper/update_exchange_rates.go (2)
  • 34-43: The loop correctly iterates over validatorPerformances and emits the new EventValidatorPerformance for each validator. Ensure that the validatorPerformance struct fields are correctly mapped to the event fields.

  • 30-46: The integration of the new event emission within the existing logic appears to be seamless and does not seem to interfere with the current functionality. However, ensure that the rest of the system correctly handles these new events.

Verification successful

The verification process has revealed that the event emission for EventValidatorPerformance is consistent with the patterns found in other parts of the codebase. There is no indication of issues with the integration of the new event within the existing logic.

  • The search for EventManager().EmitTypedEvent usage confirms that events are emitted in various modules, which aligns with the typical design of blockchain applications.
  • The lack of specific handlers for EventValidatorPerformance within the codebase is not necessarily an issue, as blockchain systems often rely on external observers to process events.

Based on the current context, the integration of the new event emission appears to be correct.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the new events are being handled wherever necessary.
rg --type go "EventValidatorPerformance"

Length of output: 2873



Script:

#!/bin/bash
# Check for generic event handling logic that might process the new event type.
rg --type go "EventManager().EmitTypedEvent"

Length of output: 46



Script:

#!/bin/bash
# Broaden the search to find any usage of EventManager to understand how events are handled.
rg --type go "EventManager()"

Length of output: 4482

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 eb7fdbf and b8f48fa.
Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
Additional comments: 2
CHANGELOG.md (2)
  • 69-69: Please confirm that the addition of new events to the oracle module constitutes a state machine breaking change, as it is listed under the "State Machine Breaking" section. If it is not state machine breaking, it should be listed under a different section such as "Features" or "Improvements".

  • 69-69: The changelog entry for PR feat(oracle): Add more events on validator's performance #1755 is well-documented and follows the established changelog conventions.

Copy link

codecov bot commented Dec 29, 2023

Codecov Report

Attention: 24 lines in your changes are missing coverage. Please review.

Comparison is base (d33dfe9) 73.89% compared to head (b8f48fa) 73.45%.
Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1755      +/-   ##
==========================================
- Coverage   73.89%   73.45%   -0.44%     
==========================================
  Files         192      195       +3     
  Lines       15142    15442     +300     
==========================================
+ Hits        11189    11343     +154     
- Misses       3297     3437     +140     
- Partials      656      662       +6     
Files Coverage Δ
app/app.go 58.06% <100.00%> (ø)
app/keepers.go 99.18% <100.00%> (-0.03%) ⬇️
app/upgrades.go 55.55% <100.00%> (ø)
cmd/nibid/cmd/root.go 80.51% <100.00%> (+0.10%) ⬆️
x/oracle/keeper/update_exchange_rates.go 94.73% <100.00%> (+0.68%) ⬆️
app/export.go 0.00% <0.00%> (ø)
cmd/nibid/cmd/decode_base64.go 72.28% <72.28%> (ø)

... and 4 files with indirect coverage changes

@matthiasmatt matthiasmatt merged commit 02d7e0b into main Dec 29, 2023
17 checks passed
@matthiasmatt matthiasmatt deleted the mat/add-oracle-events branch December 29, 2023 18:52
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.

feat(oracle): introduce new events
2 participants