Skip to content

docs: improve inline documentation for overflow prevention - #864

Open
q404365631 wants to merge 684 commits into
leojay-net:mainfrom
q404365631:docs/overflow-improvements
Open

docs: improve inline documentation for overflow prevention#864
q404365631 wants to merge 684 commits into
leojay-net:mainfrom
q404365631:docs/overflow-improvements

Conversation

@q404365631

Copy link
Copy Markdown

Closes #592

This PR updates the overflow-prevention documentation and hardens one internal counter increment:

Markdown guide updates (OVERFLOW_PREVENTION.md):

  • Added a Quick Decision Table so contributors can pick the right API at a glance
  • Added Common Pitfalls section with examples for counter increments and chained additions
  • Expanded the checklist to include internal-counter safety

Inline code improvements (lib.rs):

  • Replaced plain +1 with checked_add(1).unwrap_or(u64::MAX) for ReceiptCounter to stay consistent with the overflow-checks policy, even though u64::MAX is practically unreachable.

Godbrand0 and others added 30 commits March 29, 2026 07:17
…timization

feat: optimize chat interface for mobile viewports
I added changeloggeneration with git-cliff
…py-step

ci: add cargo clippy checks to contract workflows (leojay-net#310)
…window-isolation

test(contract): add per-user quota reset isolation test (leojay-net#319)
docs: expand README with project architecture overview
…ices

show live crypto prices in chat sidebar
…ll_denied_addresses

feat(contract): add admin-only get_all_denied_addresses query
…en_daily_deposit_limit_enforcement

test(contract): add test for per-token daily deposit limit enforcement
…or_escrow_accounting

test(contract): add invariant test for escrow accounting after migratio
Tiago-Vier-Preto and others added 29 commits April 23, 2026 02:41
…eojay-net#713

- feat(leojay-net#706): Added Zod validation to AdminGuard.tsx and unit tests
- feat(leojay-net#707): Added max bounds loop prevention in deny_address
- feat(leojay-net#710): Added circuit breaker bounds limiting in get_receipt_by_index
- fix(leojay-net#713): Corrected edge validation via explicit bounds checking in withdraw_fees
…anel-copy-docs-timeline

feat: implement issues
…inline-documentation-for-admin-authentication-logic

docs: improve inline documentation for admin authentication logic
- Replace saturating_add with checked_add in propose_upgrade so that
  an overflow in current_ledger + delay returns Error::Overflow instead
  of silently clamping to u32::MAX (which could produce an incorrect
  executable_after value)
- Add missing delay boundary check: reject delay < MIN_UPGRADE_DELAY
  with Error::UpgradeDelayTooShort to prevent zero-delay timelock bypass
- Fix off-by-one in execute_upgrade: change strict < to <= so execution
  at exactly executable_after is rejected, matching the rest of the
  timelock pattern (execute_admin_action, execute_renounce_admin)
- Add missing admin auth and paused-state check to execute_upgrade
- Add tests covering all boundary conditions and overflow edge cases

docs: improve inline documentation for overflow prevention (leojay-net#659)

- Add comprehensive Rustdoc to propose_upgrade, execute_upgrade,
  cancel_upgrade, check_invariants, require_not_paused,
  enforce_withdrawal_quota, and validate_and_increment_nonce explaining
  the overflow-prevention strategy at each site
- Expand math.rs with full Rustdoc for mul_div_floor, mul_div_ceil,
  scale_floor including overflow boundary analysis and unit tests
- Document all protocol constants with inline comments explaining their
  role in overflow-safe arithmetic
- Add docs/OVERFLOW_PREVENTION.md: architectural guide covering all
  four overflow strategies (checked_add, saturating_add, fixed-point
  math, guarded subtraction) with examples and contributor checklist
- Update docs/VERSION_MIGRATION.md with upgrade mechanism API reference
  and link to overflow guide
- Update README.md documentation table
…cs-upgrade-validation

Fix/overflow docs upgrade validation, fuzz test and invariant test
…et#695, leojay-net#687

- Issue leojay-net#62: Add Sentry integration for frontend and API error tracking
  - Install @sentry/nextjs package
  - Configure Sentry for client, server, and edge runtimes
  - Add error capturing to API routes
  - Update .env.example with SENTRY_DSN variable

- Issue leojay-net#699: Add dark mode fallback to admin/page.tsx
  - Replace hardcoded Tailwind colors with CSS tokens
  - Use theme utility classes (theme-surface, theme-text-primary, etc.)
  - Add dynamic chart colors that respond to theme changes
  - Ensure all UI elements support light/dark themes
  - Add unit tests for dark mode support

- Issue leojay-net#695: Implement replay protection for withdraw_fees
  - Add FeeWithdrawalNonce storage key per admin address
  - Require nonce parameter in withdraw_fees function
  - Validate nonce matches expected value before withdrawal
  - Increment nonce after successful withdrawal
  - Add get_fee_withdrawal_nonce getter function
  - Add comprehensive tests for replay protection

- Issue leojay-net#687: Fix edge case validation in request_withdrawal
  - Validate token is whitelisted before processing
  - Check withdrawal amount doesn't exceed contract balance
  - Validate liabilities won't overflow
  - Ensure new liabilities don't exceed net deposited amount
  - Prevent recipient from being contract itself
  - Add explicit error returns for all edge cases
  - Add tests for edge case validation

All features include tests and follow project conventions.
…s-62-699-695-687

Feat: Sentry Features Implementation
Adds set_emergency_recovery with capped limits and event emission, introduces overflow-safe counters in execute_batch_admin and heartbeat nonce progression, and expands pause/emergency/batch regression tests for the assigned upstream issues.

Made-with: Cursor
feat(frontend): add accessible avatar contrast normalization to chat …
Keep rapid filter interactions consistent by tracking pending filter selections until the debounced URL sync completes. Add hook tests that verify batched debounced updates and immediate optimistic filtering behavior.

Made-with: Cursor
- SplitViewComparison: semantic CSS variables, regions, toolbar, dialog labelling (leojay-net#638 leojay-net#643)
- LandingPage: main landmark, section labels, form label, social link labels (leojay-net#640)
- PriceTicker: focused keyboard shortcuts + tests (leojay-net#648)

Made-with: Cursor
…ntend-a11y-theme-ticker-638-640-643-648

feat(frontend): SplitView tokens/ARIA, Landing ARIA, PriceTicker shortcuts
…62-564

feat: set_limit cap, ReceiptDrawer E2E, fiat telemetry, heartbeat invariants
- leojay-net#634: Rustdoc for check_slippage + docs/slippage-threshold.md + README link
- leojay-net#637: Zod validation for StellarFiatModal submit paths
- leojay-net#639: Theme-aligned divider classes from useFeatureFlag + regression test
- leojay-net#641: AbortController on AuditTable fetches + regression test

Made-with: Cursor
…7-639-641

fix: slippage docs, Zod fiat modal, feature-flag borders, audit race
…nce-transaction-filters

feat(frontend): debounce transaction filters with optimistic state
…work toasts

- Add Soroban invariant tests for pause and execute_batch_admin
- Repair corrupted/duplicate tests in test.rs for SDK API drift
- Network status toasts in SplitViewComparison and AIAssistant fetch paths
- Unit tests for toast behavior

Made-with: Cursor
…ues-538-554-550-563

test(contract): pause & batch admin invariants; network toasts (DRIPS)
- Add Quick Decision Table to OVERFLOW_PREVENTION.md for fast API selection
- Add Common Pitfalls section covering counter increments and chained additions
- Update checklist to include internal-counter safety
- Replace plain +1 with checked_add(1).unwrap_or(u64::MAX) for ReceiptCounter
  in lib.rs for defensive consistency with overflow-checks policy
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.

docs: improve inline documentation for overflow prevention