Skip to content

fix: MEV mitigation, invoice count safety, batch reputation, pause ch… - #614

Merged
Levi-Ojukwu merged 2 commits into
Invoice-Liquidity-Network:mainfrom
Anthony-19:fix/mev-mitigation-invoice-count-batch-rep-pause-checks
Jul 28, 2026
Merged

fix: MEV mitigation, invoice count safety, batch reputation, pause ch…#614
Levi-Ojukwu merged 2 commits into
Invoice-Liquidity-Network:mainfrom
Anthony-19:fix/mev-mitigation-invoice-count-batch-rep-pause-checks

Conversation

@Anthony-19

Copy link
Copy Markdown
Contributor

Issue #MEV-1 — Mitigate MEV/front-running in resolve_fund_queue

  • Add QUEUE_DELAY_LEDGERS = 120 constant (~10 min at 5s/ledger) to constants.rs
  • Add QueueNotMature = 39 error variant to errors.rs
  • Add DataKey::FundQueueOpenedAt(u64) storage key to storage.rs
  • Add try_set_fund_queue_opened_at / get_fund_queue_opened_at helpers in
    both storage.rs and invoice.rs
  • join_fund_queue records the ledger sequence when the first LP joins
  • resolve_fund_queue enforces the maturity delay; rejects with QueueNotMature
    if the delay has not elapsed, preventing same-block front-running
  • Add FundQueueResolutionAttempted event (emitted on both success and failure)
    so off-chain monitors can detect MEV probing
  • Tests: tests_mev_mitigation.rs (10 tests covering: reject before delay,
    succeed after delay, timer anchored to first join, idempotency, events)

Issue #invoice-count — Fix get_invoice_count underflow before initialization

  • get_invoice_count now uses saturating_sub(1) so an uninitialized contract
    (read_next_invoice_id defaults to 1) returns 0 instead of panicking
  • Tests: tests_invoice_count.rs (5 tests covering: uninitialized, post-init,
    after first submit, N submits, batch submit count)

Issue #batch-reputation — Fix batch_submit not incrementing invoices_submitted

  • Add increment_invoices_submitted(&env, &params.freelancer) inside the
    submit_invoices_batch loop, mirroring the single submit_invoice path
  • Tests: tests_batch_submit_reputation.rs (5 tests covering: 3-invoice batch,
    cumulative batches, two freelancers in one batch, parity with single submit,
    no paid/defaulted side-effects)

Issue #pause-checks — Add missing pause guards to expire_invoice and appeal_default

@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@Anthony-19 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

cargo-deny's wildcard ban (allow-wildcard-paths = true) only applies to
non-publishable crates. invoice_liquidity had no publish = false, so
cargo-deny treated it as a public crate and rejected the path dependency
on insurance_pool.

Setting publish = false is consistent with insurance_pool and fuzz, which
already carry this field.

Fixes: error[wildcard] in bans check
@Levi-Ojukwu
Levi-Ojukwu merged commit db871af into Invoice-Liquidity-Network:main Jul 28, 2026
4 checks passed
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