fix(oracle): require strict majority for weighted median#243
Conversation
Fixes KiiChain#236 The WeightedMedianWithAssertion function incorrectly used >= for the majority check. With odd total power (e.g., 101), integer division gives threshold=50, allowing a validator with exactly 50 power (49.5%) to be selected as median. Changed to > to require strict majority.
WalkthroughThe PR changes the oracle weighted median selection: Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Added tests to verify strict majority (>50%) is required for weighted median.
ad25585 to
82488b9
Compare
Description
Fixes #236
spotted a bug in
WeightedMedianWithAssertion- it uses>=for the majority check but that breaks with odd total powerexample: if total power is 101, then
101/2 = 50in go. so a validator with 50 power passes even tho thats only 49.5%just changed
>=to>so it needs actual majorityType of change
How Has This Been Tested?
PR Checklist:
make lint-fix