Skip to content

eager prune for lockup#810

Open
ozgunozerk wants to merge 4 commits into
mainfrom
l-09
Open

eager prune for lockup#810
ozgunozerk wants to merge 4 commits into
mainfrom
l-09

Conversation

@ozgunozerk

@ozgunozerk ozgunozerk commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Fixes #809

PR Checklist

  • Tests
  • Documentation

Summary by CodeRabbit

  • New Features

    • Added a maximum capacity of 512 active lock entries per token and wallet.
    • Expired lock entries are automatically removed before new locks are recorded.
    • Added clear error reporting when minting or presetting locks exceeds the capacity limit.
  • Bug Fixes

    • Prevented expired locks from incorrectly contributing to capacity limits.
    • Added coverage for lock pruning, capacity enforcement, and boundary conditions.

@ozgunozerk
ozgunozerk requested a review from brozorec July 21, 2026 13:30
@ozgunozerk ozgunozerk self-assigned this Jul 21, 2026
@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.63%. Comparing base (275f126) to head (daf4da7).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #810   +/-   ##
=======================================
  Coverage   96.62%   96.63%           
=======================================
  Files          71       71           
  Lines        7345     7365   +20     
=======================================
+ Hits         7097     7117   +20     
  Misses        248      248           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bidzyyys

bidzyyys commented Jul 21, 2026

Copy link
Copy Markdown

Review — stellar-tokens

  • src/rwa/compliance/modules/initial_lockup_period/storage.rs:269 — new doc claims the vector "cannot grow past the ledger-entry size limit under repeated issuance," but pruning only drops expired entries; many mints inside a single still-open lockup window still accumulate unbounded active locks (exactly the residual L-09's own text describes) → soften to "bounded by the number of concurrently-active locks" to match the accurate wording already used in mod.rs:42-45.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0d83ba15-3e2e-4b1e-8ee4-4c54baf86b5a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

Initial lockup periods now define a 512-entry active-lock limit, prune expired locks during mints, reject oversized presets or mint schedules with LockBoundExceeded, and test pruning and boundary behavior.

Changes

Bounded lockup lifecycle

Layer / File(s) Summary
Lock bound contract
packages/tokens/src/rwa/compliance/modules/initial_lockup_period/mod.rs, packages/tokens/src/rwa/compliance/modules/mod.rs
Defines MAX_LOCKS = 512, documents the capacity behavior, and adds ComplianceModuleError::LockBoundExceeded.
Storage pruning and enforcement
packages/tokens/src/rwa/compliance/modules/initial_lockup_period/storage.rs
Validates preset sizes, prunes expired locks during on_created, updates total_locked, and rejects full active-lock sets.
Pruning and boundary coverage
packages/tokens/src/rwa/compliance/modules/initial_lockup_period/test.rs
Tests expired-lock pruning, active-lock preservation, capacity failures, expiry-assisted minting, and oversized presets.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Ledger
  participant on_created
  participant prune_expired_locks
  participant LockStorage
  Ledger->>on_created: mint at current ledger time
  on_created->>prune_expired_locks: remove expired locks
  prune_expired_locks->>LockStorage: update locks and total_locked
  on_created->>LockStorage: append lock or raise LockBoundExceeded
Loading

Suggested reviewers: brozorec

Poem

A rabbit counts locks, one hop at a time,
Prunes old entries in orderly rhyme.
Five hundred twelve fit neatly in line,
Full shelves raise an error sign.
Fresh minting now keeps storage fine!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and clearly describes the eager lockup pruning change.
Description check ✅ Passed The description matches the template, links issue #809, and includes checked tests and documentation.
Linked Issues check ✅ Passed The changes eagerly prune expired mint lockups on mint and add tests/docs for the new bound behavior.
Out of Scope Changes check ✅ Passed All code changes support the lockup pruning and capacity-bound behavior; no unrelated changes stand out.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch l-09

Comment @coderabbitai help to get the list of available commands.

@ozgunozerk
ozgunozerk requested a review from brozorec July 24, 2026 07:41

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/tokens/src/rwa/compliance/modules/initial_lockup_period/storage.rs`:
- Around line 451-465: Update the lock-pruning loop to track whether any lock
expired independently of the accumulated pruned amount, including zero-valued
locks. In the surrounding pruning logic, replace details.locks whenever an
expired entry was found, while only subtracting pruned from total_locked when
pruned is positive; add a regression test covering expired zero-value entries at
MAX_LOCKS.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 671e22eb-9696-42e2-ba3b-21710b50eca0

📥 Commits

Reviewing files that changed from the base of the PR and between 3c02740 and 1fa3612.

📒 Files selected for processing (4)
  • packages/tokens/src/rwa/compliance/modules/initial_lockup_period/mod.rs
  • packages/tokens/src/rwa/compliance/modules/initial_lockup_period/storage.rs
  • packages/tokens/src/rwa/compliance/modules/initial_lockup_period/test.rs
  • packages/tokens/src/rwa/compliance/modules/mod.rs

Comment thread packages/tokens/src/rwa/compliance/modules/initial_lockup_period/storage.rs Outdated
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.

[L-09] - lazy pruning for mint lockups, may grow too quickly

3 participants