Skip to content

Conversation

@Thaleszh
Copy link
Contributor

@Thaleszh Thaleszh commented Jan 6, 2026

Description

Adds distributed reward and total distributed to telemetry at begin blocks

Type of change

  • New feature (non-breaking change which adds functionality)

@Thaleszh Thaleszh requested a review from jhelison as a code owner January 6, 2026 14:08
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 6, 2026

Walkthrough

BeginBlocker in x/rewards/keeper/abci.go now returns any error from ReleaseSchedule.Set instead of ignoring it. After saving the updated schedule, BeginBlocker calls a new Keeper method WriteRewardMetrics(ctx, distributed, total). WriteRewardMetrics converts amounts to float64 (logs conversion errors) and emits two telemetry gauges: reward_released (distributed) and total_reward_released (total). CHANGELOG.md was updated with "Added telemetry for reward distribution."

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding telemetry for reward information, which aligns with the core objective of emitting telemetry metrics for reward distribution.
Description check ✅ Passed The description is directly related to the changeset, explaining that it adds distributed reward and total distributed metrics to telemetry at begin blocks, which matches the implementation of WriteRewardMetrics.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1838e29 and 8427e8b.

📒 Files selected for processing (1)
  • x/rewards/keeper/abci.go
🧰 Additional context used
🧬 Code graph analysis (1)
x/rewards/keeper/abci.go (2)
x/rewards/keeper/keeper.go (1)
  • Keeper (18-32)
x/rewards/types/keys.go (1)
  • ModuleName (13-13)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: tests
  • GitHub Check: golangci-lint
  • GitHub Check: Analyze
  • GitHub Check: test-e2e
  • GitHub Check: golangci-lint
🔇 Additional comments (2)
x/rewards/keeper/abci.go (2)

69-76: LGTM - Proper error handling and telemetry integration.

The error from ReleaseSchedule.Set is now correctly propagated. Calling WriteRewardMetrics after successful state persistence ensures metrics are only emitted for committed distributions.


78-111: Well-implemented telemetry with safe float conversion.

The implementation correctly addresses the prior review concerns:

  • Uses Float64() with error handling instead of MustFloat64(), eliminating panic risk
  • Logs conversion errors with useful context for debugging
  • Follows the established pattern from x/feeabstraction/keeper/abci.go

The float64float32 cast is required by ModuleSetGauge's API signature. While precision is reduced, this is acceptable for observability purposes where approximate values suffice.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Jan 6, 2026

Codecov Report

❌ Patch coverage is 0% with 31 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
x/rewards/keeper/abci.go 0.00% 31 Missing ⚠️

📢 Thoughts on this report? Let us know!

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: 1

🤖 Fix all issues with AI Agents
In @x/rewards/keeper/abci.go:
- Around line 79-90: The WriteRewardMetrics function uses
Amount.ToLegacyDec().MustFloat64() and then casts to float32 which risks panic
and precision loss; replace MustFloat64() with ToLegacyDec().Float64() and
handle the returned error (as done in x/feeabstraction/keeper/abci.go): if
Float64() returns an error, log the error via the keeper logger and use a safe
fallback value (e.g., 0) for the telemetry gauge, and only cast to float32 when
passing into telemetry.ModuleSetGauge(types.ModuleName, ...) after confirming a
valid float64 was obtained.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 643987f and b2c8fe9.

📒 Files selected for processing (1)
  • x/rewards/keeper/abci.go
🧰 Additional context used
🧬 Code graph analysis (1)
x/rewards/keeper/abci.go (2)
x/rewards/keeper/keeper.go (1)
  • Keeper (18-32)
x/rewards/types/keys.go (1)
  • ModuleName (13-13)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: golangci-lint
  • GitHub Check: test-e2e
  • GitHub Check: tests
  • GitHub Check: liveness-test
  • GitHub Check: Analyze
🔇 Additional comments (1)
x/rewards/keeper/abci.go (1)

69-76: LGTM on the error handling refactor.

Explicit error handling before emitting telemetry ensures metrics are only recorded after successful state updates.

@Thaleszh Thaleszh merged commit f4098e4 into main Jan 6, 2026
9 of 10 checks passed
@Thaleszh Thaleszh deleted the feat/rewards-telemetry branch January 6, 2026 20:33
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.

3 participants