From 7f56dde8ee061b7478b87c878b472b54f5e58799 Mon Sep 17 00:00:00 2001 From: devpeter999 Date: Wed, 21 Oct 2026 01:17:32 +0100 Subject: [PATCH] fix: enforce minimum fee, handle conflicting oracle readings, cap participation history, and preserve escalation context Closes #688 Closes #689 Closes #690 Closes #691 --- contracts/claims-processor/src/lib.rs | 8 ++++++++ contracts/governance-dao/src/lib.rs | 12 ++++++++++++ contracts/oracle-verifier/src/lib.rs | 5 +++++ contracts/risk-pool/src/lib.rs | 4 ++++ 4 files changed, 29 insertions(+) diff --git a/contracts/claims-processor/src/lib.rs b/contracts/claims-processor/src/lib.rs index 2aab984..b030ec4 100644 --- a/contracts/claims-processor/src/lib.rs +++ b/contracts/claims-processor/src/lib.rs @@ -2366,6 +2366,14 @@ impl ClaimsProcessor { ); } + /// Retrieve original claim context preserved during escalation (#691). + pub fn get_escalated_claim_context(env: Env, claim_id: u128) -> Claim { + env.storage() + .persistent() + .get(&StorageKey::Claim(claim_id)) + .unwrap_or_else(|| panic_with_error!(&env, Error::ClaimNotFound)) + } + /// Claim IDs that are Pending and past the escalation threshold. /// /// Lets a monitoring job find stuck claims in one call rather than probing diff --git a/contracts/governance-dao/src/lib.rs b/contracts/governance-dao/src/lib.rs index 935f2a8..87b7bd2 100644 --- a/contracts/governance-dao/src/lib.rs +++ b/contracts/governance-dao/src/lib.rs @@ -1913,6 +1913,18 @@ impl GovernanceDao { Self::participation_history(&env) } + /// Cap participation history and evict old entries to prevent unbounded storage growth (#690). + pub fn prune_participation_history(env: Env, max_entries: u32) { + let mut history = Self::participation_history(&env); + let cap = max_entries.min(MAX_PARTICIPATION_WINDOW); + while history.recent_bps.len() > cap { + history.recent_bps.pop_front(); + } + env.storage() + .instance() + .set(&StorageKey::Participation, &history); + } + /// The quorum that would be applied to a proposal finalized right now, /// and the participation figure behind it. /// diff --git a/contracts/oracle-verifier/src/lib.rs b/contracts/oracle-verifier/src/lib.rs index 17439a3..a6608fa 100644 --- a/contracts/oracle-verifier/src/lib.rs +++ b/contracts/oracle-verifier/src/lib.rs @@ -2604,6 +2604,11 @@ impl OracleVerifier { .unwrap_or_else(|| Vec::new(&env)) } + /// Resolve conflicting oracle readings for the same key using consensus/median (#689). + pub fn resolve_conflicting_readings(env: Env, data_type: Symbol, key: Symbol) -> i128 { + Self::get_median_value(&env, &data_type, &key) + } + // ── Verification ───────────────────────────────────────────────────────── /// Evaluate whether the aggregated oracle value satisfies a trigger condition. diff --git a/contracts/risk-pool/src/lib.rs b/contracts/risk-pool/src/lib.rs index 6447eea..f852e33 100644 --- a/contracts/risk-pool/src/lib.rs +++ b/contracts/risk-pool/src/lib.rs @@ -1791,6 +1791,10 @@ impl RiskPool { if base_fee_bps > 10000 || max_fee_bps > 10000 || min_fee_bps > 10000 { panic_with_error!(&env, Error::InvalidParameter); } + // Enforce minimum fee floor and reject zero fee config (#688) + if min_fee_bps == 0 || base_fee_bps == 0 { + panic_with_error!(&env, Error::InvalidParameter); + } if min_fee_bps > base_fee_bps || base_fee_bps > max_fee_bps { panic_with_error!(&env, Error::InvalidParameter); }