Skip to content

refactor: route i128 hot paths through safe_math wrappers#498

Open
ayo-ola0710 wants to merge 1 commit into
RevoraOrg:masterfrom
ayo-ola0710:refactor/safe-math-module
Open

refactor: route i128 hot paths through safe_math wrappers#498
ayo-ola0710 wants to merge 1 commit into
RevoraOrg:masterfrom
ayo-ola0710:refactor/safe-math-module

Conversation

@ayo-ola0710

Copy link
Copy Markdown

What was done

A new safe_math module was introduced to centralize overflow-resistant arithmetic via a SafeMath trait that exposes s_add, s_sub, s_mul, and s_div operations returning a Result<Self, RevoraError>. Using this new module, hot paths in the codebase—specifically the compute_share calculation, supply cap and revenue accrual updates in deposit_revenue and report_revenue, and the reconcile_audit_summary aggregation loop—were refactored to replace silent saturating_* and raw checked_* patterns with explicit error-handling boundaries. Finally, comprehensive unit tests were added to safe_math.rs, and the strict #![deny(clippy::arithmetic_side_effects)] lint was enforced across all touched files (lib.rs, security_assertions.rs, and safe_math.rs) to guarantee future arithmetic safety.

Close #484

@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@ayo-ola0710 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Add safe-math wrapper module enforcing checked arithmetic across all i128 operations

1 participant