Skip to content

YNU-831: feat: non-slashable app registry#2

Merged
mod merged 6 commits intomasterfrom
feat/app-registry
Mar 5, 2026
Merged

YNU-831: feat: non-slashable app registry#2
mod merged 6 commits intomasterfrom
feat/app-registry

Conversation

@nksazonov
Copy link
Collaborator

@nksazonov nksazonov commented Mar 5, 2026

Summary by CodeRabbit

  • New Features

    • Introduced NonSlashableAppRegistry contract for managing collateral with configurable unlock periods and reentrancy protection
    • Enhanced lock mechanism to support target-based deposits
    • Updated withdraw function to specify destination addresses
    • Improved event payloads with detailed balance and deposit information
  • Tests

    • Added comprehensive test coverage for new registry contract and updated locking mechanics across all implementations

@coderabbitai
Copy link

coderabbitai bot commented Mar 5, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: dcd92a9d-27f5-4f49-9c9e-980c91ffe2f4

📥 Commits

Reviewing files that changed from the base of the PR and between b33ec19 and f31b076.

📒 Files selected for processing (9)
  • src/AppRegistry.sol
  • src/NodeRegistry.sol
  • src/NonSlashableAppRegistry.sol
  • src/interfaces/ILock.sol
  • test/AppRegistry.t.sol
  • test/Governor.t.sol
  • test/NodeRegistry.t.sol
  • test/NodeRegistryVotes.t.sol
  • test/NonSlashableAppRegistry.t.sol

📝 Walkthrough

Walkthrough

Introduces a new NonSlashableAppRegistry contract implementing per-target collateral management with unlock periods, modifies the ILock interface and existing lock/unlock registries to accept target and destination addresses, and provides comprehensive test coverage across all affected contracts.

Changes

Cohort / File(s) Summary
New NonSlashableAppRegistry Implementation
src/NonSlashableAppRegistry.sol
New contract implementing ILock with per-user collateral balances, unlock timestamps, and state management. Includes lock, unlock, relock, and withdraw functions with reentrancy protection and SafeERC20 integration.
ILock Interface Updates
src/interfaces/ILock.sol
Function signatures updated: lock() now takes address target parameter; withdraw() now takes address destination parameter. Event payloads expanded: Locked, UnlockInitiated, Relocked, Withdrawn events now include additional balance/amount details.
Core Registry Implementations
src/AppRegistry.sol, src/NodeRegistry.sol
Both contracts updated to match new ILock interface: lock(address target, uint256 amount) deposits to target's balance; withdraw(address destination) transfers to specified destination. State tracking and event emissions updated accordingly.
AppRegistry Test Suite
test/AppRegistry.t.sol
Test structure refactored from monolithic to modular with separate test contracts for constructor, initial state, lock, unlock, relock, withdraw, and slash flows. All test calls updated to pass explicit target/destination addresses.
NonSlashableAppRegistry Test Suite
test/NonSlashableAppRegistry.t.sol
New comprehensive test file with base fixture and eight test contract modules covering constructor validation, state checks, lock/unlock/relock/withdraw flows, and full lifecycle scenarios.
Remaining Test Files
test/Governor.t.sol, test/NodeRegistry.t.sol, test/NodeRegistryVotes.t.sol
All test invocations updated to use new function signatures: lock(address, uint256) and withdraw(address) throughout test scenarios and assertions.

Sequence Diagram(s)

sequenceDiagram
    participant User as User/Caller
    participant Registry as NonSlashableAppRegistry
    participant Token as ASSET Token
    
    User->>Registry: lock(target, amount)
    activate Registry
    Registry->>Token: transferFrom(user, registry, amount)
    activate Token
    Token-->>Registry: ✓ transfer success
    deactivate Token
    Registry->>Registry: update target balance & state
    Registry-->>User: emit Locked(target, amount, newBalance)
    deactivate Registry
    
    User->>Registry: unlock()
    activate Registry
    Registry->>Registry: set unlock timestamp = now + UNLOCK_PERIOD
    Registry->>Registry: set state = UNLOCKING
    Registry-->>User: emit UnlockInitiated(user, balance, timestamp)
    deactivate Registry
    
    Note over User,Registry: Wait for unlock period...
    
    User->>Registry: withdraw(destination)
    activate Registry
    Registry->>Token: transfer(destination, balance)
    activate Token
    Token-->>Registry: ✓ transfer success
    deactivate Token
    Registry->>Registry: reset balance & unlock timestamp
    Registry-->>User: emit Withdrawn(user, balance)
    deactivate Registry
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~28 minutes

Poem

🐰 A new vault springs up where targets thrive,
With unlock timers and withdrawals live,
No slashing here—just collateral care,
Lock, wait, relock: a dance so fair!
The registry hops with state so neat,
Making per-target locking complete! 🌟


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

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

@mod mod merged commit d21b85a into master Mar 5, 2026
3 checks passed
@mod mod deleted the feat/app-registry branch March 5, 2026 14:25
mod pushed a commit that referenced this pull request Mar 5, 2026
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.

2 participants