fix(oracle): handle errors in pickReferenceDenom instead of panic#232
Conversation
WalkthroughThe Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧬 Code graph analysis (1)x/oracle/tally_test.go (4)
🔇 Additional comments (4)
✏️ Tip: You can disable this entire section by setting 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. Comment |
7027019 to
89cbb55
Compare
There was a problem hiding this comment.
Hello there! Nice PR ongoing, but there are a few things requiring change:
- The code you pushed is using a different spacing lint. Run
make lint-fixto ensure it has the same pattern as the repo's. It will also make it much better for reviewing. You can check if it's working by reviewing the change tab on the PR, it should only highlight your changes. - Each change must be documented in the changelog. Please add the fix you are pushing under
Unreleased > Fixed - It is also good practice to add tests cases on
tally_test.gothat checks the new behaviors introduced.
89cbb55 to
0e7234c
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@CHANGELOG.md`:
- Line 20: The CHANGELOG.md contains a duplicate entry "Handle ignored error
from TotalBondedTokens in pickReferenceDenom
[`#230`](https://github.com/KiiChain/kiichain/issues/230)" appearing in both the
UNRELEASED section and the v6.0.0 section; remove the duplicate so the fix is
listed only once (preferably keep it under UNRELEASED until release), ensuring
the remaining entry stays correctly formatted under the intended section header.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
CHANGELOG.mdx/oracle/tally.go
🧰 Additional context used
🧬 Code graph analysis (1)
x/oracle/tally.go (1)
x/oracle/types/expected_keepers.go (1)
StakingKeeper(17-24)
🔇 Additional comments (3)
x/oracle/tally.go (3)
21-27: Critical fix for the threshold bypass vulnerability.This properly addresses issue
#230. Previously, ignoring the error fromTotalBondedTokenswould result intotalBondedTokens = 0, causingthresholdVotes = 0, which would allow any ballot to pass regardless of actual voting power. The fix correctly propagates the error to prevent oracle manipulation.
72-72: LGTM!Correct success return with
nilerror, consistent with the error-returning paths.
15-15: Function signature updated to return error — all callers properly handle the returned error.The signature change to return an error is the correct approach for proper error propagation. Verification confirms that all callers in
abci.go(lines 78-80) andtally_test.go(lines 100, 217) correctly handle the returned error. The error handling forTotalBondedTokensandParams.Getis properly implemented.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
- Add error handling for TotalBondedTokens call in pickReferenceDenom - Remove duplicate changelog entry - Fixes KiiChain#230
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Thaleszh
left a comment
There was a problem hiding this comment.
Looking excellent. Just have a nitpick on missing docstring on some tests
Thaleszh
left a comment
There was a problem hiding this comment.
Looking good, waiting for pipelines and then will merge
fix(oracle): handle errors in pickReferenceDenom instead of panic
_Fixes #230
Description
In
x/oracle/tally.go, thepickReferenceDenomfunction has two error handling issues:TotalBondedTokens()is ignored with_Params.Get()causes panic instead of returning errorThis PR restructures
pickReferenceDenomto return an error to the oracle EndBlocker, as suggested by maintainer @Thaleszh.Type of change
How Has This Been Tested?