Harden rollover fee accumulation#2380
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR makes rollover-fee accumulation overflow-safe: ChangesRollover Fee Overflow Safety
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds checked arithmetic and error propagation when accumulating rollover fees to prevent silent u64 overflow, plus a unit test covering the overflow case.
Changes:
- Make
SystemContext::set_rollover_feereturnResult<()>and usechecked_addwithProgramError::ArithmeticOverflowon overflow. - Update CPI data builders to propagate
set_rollover_feeerrors (?). - Add a unit test and a test-only constructor for
SystemContext.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| programs/system/src/processor/create_outputs_cpi_data.rs | Propagates rollover-fee accumulation failures when building output CPI data. |
| programs/system/src/processor/create_address_cpi_data.rs | Propagates rollover-fee accumulation failures when deriving new address CPI data. |
| programs/system/src/context.rs | Implements checked fee accumulation with an overflow error, and adds a regression test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| pub fn set_rollover_fee(&mut self, ix_data_index: u8, fee: u64) { | ||
| pub fn set_rollover_fee(&mut self, ix_data_index: u8, fee: u64) -> Result<()> { |
Summary
Tests
Summary by CodeRabbit
Bug Fixes
Tests