Skip to content

Fix issues 288 289 290 291#293

Merged
Luluameh merged 2 commits into
LightForgeHub:mainfrom
emdevelopa:fix-issues-288-289-290-291
Jun 24, 2026
Merged

Fix issues 288 289 290 291#293
Luluameh merged 2 commits into
LightForgeHub:mainfrom
emdevelopa:fix-issues-288-289-290-291

Conversation

@emdevelopa

@emdevelopa emdevelopa commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Pull Request Description

This PR addresses the following features and security improvements:

Summary by CodeRabbit

  • New Features

    • Added an emergency pause mode to temporarily stop key session actions and expose pause status.
    • Added a notifier service that forwards contract events to a configured webhook.
  • Bug Fixes

    • Improved session cancellation and fund handling protections.
    • Strengthened reentrancy safeguards to help prevent duplicate or unsafe contract calls.
    • Updated session note storage and related migration handling to keep data consistent.

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Note: range_3783_placeholder above is a placeholder that does not exist in <all_range_ids>; range_4c270bcc651a (removal of manual lock helpers) was assigned to the reentrancy layer. All 40 provided rangeIds are assigned exactly once across layers.


Walkthrough

Introduces a centralized ReentrancyGuard in a new security module replacing manual lock helpers across all guarded contract functions, adds emergency_pause/emergency_unpause admin entrypoints with checks in session-creating functions, renames the Session field from encrypted_notes_hash to encrypted_notes_cid, extends the Error enum with new variants, and adds a TypeScript notifier microservice that polls Soroban events and POSTs them to a webhook.

Changes

Contract: ReentrancyGuard, Emergency Pause, CID field rename

Layer / File(s) Summary
Error enum variants and ReentrancyGuard implementation
contracts/src/errors.rs, contracts/src/security.rs, contracts/src/lib.rs
Renames InsuffTreasuryBalInsufficientTreasuryBalance and ReentrancyReentrantCall; adds InsufficientAntiSpamDeposit, CircuitBreakerActive, and SessionNotExpired error variants. Adds ReentrancyGuard struct with non_reentrant and clear using a temporary storage boolean. Removes the local Error enum from lib.rs in favor of pub use errors::Error and declares pub mod security.
Reentrancy refactor across session functions
contracts/src/disputes.rs, contracts/src/lib.rs
Replaces set_reentrancy_lock/assert_not_locked with ReentrancyGuard::non_reentrant and ReentrancyGuard::clear on all early-return and success paths in settle_session, end_session, internal_settle, close_session, claim_no_show_refund, withdraw_accrued, and cancel_session_by_expert. Removes manual lock helper functions.
Emergency pause entrypoints and session guards
contracts/src/lib.rs
Adds is_emergency_paused, emergency_pause, and emergency_unpause methods gated to SuperAdmin; wires an emergency pause check into initialize_fixed_price_session, start_session, and reserve_session to return ProtocolPaused early.
Session encrypted_notes_cid field rename and propagation
contracts/src/lib.rs, contracts/src/migrations.rs, contracts/src/identity.rs, .gitignore
Renames Session.encrypted_notes_hash to encrypted_notes_cid across the struct definition, all session constructors, update_session_notes, request_data_deletion, the v1→v2 migration re-hydration and comments, the identity deletion comment, and the unit test assertion.

Notifier Microservice

Layer / File(s) Summary
Notifier service implementation and package setup
services/notifier/package.json, services/notifier/index.ts
Adds notifier-service package with ts-node entry point and @stellar/stellar-sdk/axios/dotenv dependencies. Implements sendWebhook with exponential-backoff retries (up to 5) and listenEvents polling Soroban contract events every 5 seconds, advancing an internal ledger cursor and delivering events to a configured webhook URL.

Sequence Diagram(s)

sequenceDiagram
  participant listenEvents
  participant SorobanRPC
  participant sendWebhook
  participant Webhook

  listenEvents->>SorobanRPC: getLatestLedger()
  SorobanRPC-->>listenEvents: latestLedger (cursor init)

  loop every 5 seconds
    listenEvents->>SorobanRPC: getContractEvents(cursor)
    SorobanRPC-->>listenEvents: events[]
    loop for each event
      listenEvents->>sendWebhook: sendWebhook(event)
      sendWebhook->>Webhook: POST {event_type, contract_id, topic, value, timestamp}
      alt success
        Webhook-->>sendWebhook: 2xx
      else failure with retries
        Webhook-->>sendWebhook: error
        sendWebhook->>sendWebhook: retry with exponential backoff (max 5)
      end
    end
    listenEvents->>listenEvents: advance cursor to latestLedger
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

Possibly related PRs

Poem

🐇 Hop hop, the guard is set,
No reentrant calls slip through the net.
Emergency pause? The circuit breaks!
CID replaces hash — what a wake!
A notifier polls with webhooks bright,
The rabbit keeps the ledger right.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title only lists issue numbers and does not describe the actual changes in the PR. Use a concise, descriptive title that summarizes the main change, such as adding webhooks, IPFS notes, reentrancy protection, and emergency pause support.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@Luluameh Luluameh merged commit a4b46d0 into LightForgeHub:main Jun 24, 2026
1 check was pending
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