From 415bef262a0afad0d7ec8facbea887c0b306e23f Mon Sep 17 00:00:00 2001 From: Malte Kliemann Date: Fri, 5 Apr 2024 19:30:05 +0200 Subject: [PATCH] No longer allow `ResolveOrigin` to report a market (#1266) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- zrml/prediction-markets/src/lib.rs | 12 +++--------- zrml/prediction-markets/src/tests/report.rs | 13 ------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/zrml/prediction-markets/src/lib.rs b/zrml/prediction-markets/src/lib.rs index e4d2c405c..59694b7e7 100644 --- a/zrml/prediction-markets/src/lib.rs +++ b/zrml/prediction-markets/src/lib.rs @@ -3047,14 +3047,10 @@ mod pallet { } let sender_is_oracle = sender == market.oracle; - let origin_has_permission = T::ResolveOrigin::ensure_origin(origin).is_ok(); - let sender_is_outsider = !sender_is_oracle && !origin_has_permission; + let sender_is_outsider = !sender_is_oracle; if should_check_origin { - ensure!( - sender_is_oracle || origin_has_permission, - Error::::ReporterNotOracle - ); + ensure!(sender_is_oracle, Error::::ReporterNotOracle); } else if sender_is_outsider { let outsider_bond = T::OutsiderBond::get(); @@ -3096,9 +3092,7 @@ mod pallet { ) -> DispatchResultWithPostInfo { >::mutate_market(&market_id, |market| { let sender = ensure_signed(origin.clone())?; - let sender_is_oracle = sender == market.oracle; - let origin_has_permission = T::ResolveOrigin::ensure_origin(origin).is_ok(); - ensure!(sender_is_oracle || origin_has_permission, Error::::ReporterNotOracle); + ensure!(sender == market.oracle, Error::::ReporterNotOracle); market.report = Some(market_report.clone()); market.status = MarketStatus::Reported; Ok(()) diff --git a/zrml/prediction-markets/src/tests/report.rs b/zrml/prediction-markets/src/tests/report.rs index 63d4df739..bda4ccf2e 100644 --- a/zrml/prediction-markets/src/tests/report.rs +++ b/zrml/prediction-markets/src/tests/report.rs @@ -58,19 +58,6 @@ fn it_allows_to_report_the_outcome_of_a_market() { assert_eq!(market_after.status, MarketStatus::Reported); assert_eq!(report.outcome, OutcomeReport::Categorical(1)); assert_eq!(report.by, market_after.oracle); - - // Reset and report again as approval origin - let _ = MarketCommons::mutate_market(&0, |market| { - market.status = MarketStatus::Closed; - market.report = None; - Ok(()) - }); - - assert_ok!(PredictionMarkets::report( - RuntimeOrigin::signed(SUDO), - 0, - OutcomeReport::Categorical(1) - )); }); }