Skip to content

feat: resolve issues #294, #308, #295, #297 - #393

Open
serverlessdomain-hash wants to merge 1 commit into
cocor-tech:masterfrom
serverlessdomain-hash:feat/resolve-issues-294-308-295-297
Open

feat: resolve issues #294, #308, #295, #297#393
serverlessdomain-hash wants to merge 1 commit into
cocor-tech:masterfrom
serverlessdomain-hash:feat/resolve-issues-294-308-295-297

Conversation

@serverlessdomain-hash

Copy link
Copy Markdown

Closes #294
Closes #308
Closes #295
Closes #297

Summary of Changes

1. Reputation-registry storage unchecked overflow in increment functions (#294)

  • Fix: Replaced plain + 1 arithmetic with saturating_add(1) in increment_streak, increment_completions, and increment_defaults within packages/reputation-registry/src/storage.rs.
  • Impact: Prevents storage counters from overflowing and wrapping/panicking under high volume or extreme values.

2. Staking UNBONDING_PERIOD_SECONDS getter and usage clarity (#308)

  • Fix: Added public getter function get_unbonding_period_seconds(&Env) -> u64 in packages/staking/src/contract.rs and exposed get_unbonding_period_seconds(Env) -> u64 on the Staking contract interface in packages/staking/src/lib.rs.
  • Impact: Exposes the 14-day unbonding period duration constant (1,209,600 seconds) to external callers and frontends.

3. Reputation-registry negative payment amount cast protection (#295)

  • Fix: Added input validation assert!(amount >= 0, "amount must be non-negative"); and defensive bounds handling let safe_amount = amount.max(0); in record_on_time_payment in packages/reputation-registry/src/scoring.rs.
  • Impact: Prevents negative amount parameters from being cast to u32 and producing unexpectedly high volume bonuses.

4. Escrow-swap storage refactoring to Map for O(1) performance (#297)

  • Fix: Refactored DataKey::SwapRequests storage from Vec<SwapRequest> to Map<u64, SwapRequest> in packages/escrow-swap/src/contract.rs. Updated create_swap, accept_swap, complete_swap, cancel_swap, and get_swap to use direct O(1) key lookups and writes, while get_swaps() efficiently returns swaps.values().
  • Impact: Eliminates O(n) iteration across swap lists, preventing scale degradation and high gas fees as swap counts grow.

Testing & Verification

  • Unit test suites added for saturating arithmetic in reputation storage, negative amount validation in scoring, and get_unbonding_period_seconds in staking.
  • Full test suites executed across all modified packages (reputation-registry, staking, escrow-swap) with all 51 tests passing cleanly.

@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@serverlessdomain-hash 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

@cypriannwokolo2-creator

Copy link
Copy Markdown
Contributor

This PR (and its peer master state) has merge conflicts in packages/{escrow-swap,reputation-registry,staking}. While reviewing I also found the current master staking package does not compile (pre-existing duplicate get_stake_amount/get_all_stakers and an undefined StakersList), separate from your changes. Could you rebase onto latest master and re-run the staking/reputation-registry tests? Happy to merge once it's green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants