From 4849f8e77dce98668b4ca1a2154ab47ebfb6f0c8 Mon Sep 17 00:00:00 2001 From: Bryan Chen Date: Fri, 9 Jul 2021 18:44:41 +1200 Subject: [PATCH 1/3] include dispatch result in the Executed event --- frame/democracy/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 6ebe917f56ae5..2ed834dc26f72 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -510,8 +510,8 @@ pub mod pallet { NotPassed(ReferendumIndex), /// A referendum has been cancelled. \[ref_index\] Cancelled(ReferendumIndex), - /// A proposal has been enacted. \[ref_index, is_ok\] - Executed(ReferendumIndex, bool), + /// A proposal has been enacted. \[ref_index, result\] + Executed(ReferendumIndex, DispatchResult), /// An account has delegated their vote to another account. \[who, target\] Delegated(T::AccountId, T::AccountId), /// An \[account\] has cancelled a previous delegation operation. @@ -1652,8 +1652,8 @@ impl Pallet { debug_assert!(err_amount.is_zero()); Self::deposit_event(Event::::PreimageUsed(proposal_hash, provider, deposit)); - let ok = proposal.dispatch(frame_system::RawOrigin::Root.into()).is_ok(); - Self::deposit_event(Event::::Executed(index, ok)); + let res = proposal.dispatch(frame_system::RawOrigin::Root.into()); + Self::deposit_event(Event::::Executed(index, res)); Ok(()) } else { From ce58ea3baf823ad133cea9d010f3199b05e76efb Mon Sep 17 00:00:00 2001 From: Bryan Chen Date: Fri, 9 Jul 2021 18:52:54 +1200 Subject: [PATCH 2/3] fix --- frame/democracy/src/benchmarking.rs | 4 ++-- frame/democracy/src/lib.rs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/frame/democracy/src/benchmarking.rs b/frame/democracy/src/benchmarking.rs index d1d3b3e62bddd..ef2c7de27ba59 100644 --- a/frame/democracy/src/benchmarking.rs +++ b/frame/democracy/src/benchmarking.rs @@ -25,7 +25,7 @@ use frame_support::{ traits::{Currency, Get, EnsureOrigin, OnInitialize, UnfilteredDispatchable, schedule::DispatchTime}, }; use frame_system::{RawOrigin, Pallet as System, self}; -use sp_runtime::traits::{Bounded, One}; +use sp_runtime::traits::{Bounded, One, BadOrigin}; use crate::Pallet as Democracy; @@ -759,7 +759,7 @@ benchmarks! { }: enact_proposal(RawOrigin::Root, proposal_hash, 0) verify { // Fails due to mismatched origin - assert_last_event::(Event::::Executed(0, false).into()); + assert_last_event::(Event::::Executed(0, Err(BadOrigin.into())).into()); } #[extra] diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 2ed834dc26f72..b1310efea2401 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -1652,7 +1652,8 @@ impl Pallet { debug_assert!(err_amount.is_zero()); Self::deposit_event(Event::::PreimageUsed(proposal_hash, provider, deposit)); - let res = proposal.dispatch(frame_system::RawOrigin::Root.into()); + let res = proposal.dispatch(frame_system::RawOrigin::Root.into()) + .map(|_| ()).map_err(|e| e.error); Self::deposit_event(Event::::Executed(index, res)); Ok(()) From 4a21edb52b0544a8c466d0f6a08ad2815cf74344 Mon Sep 17 00:00:00 2001 From: Bryan Chen Date: Thu, 15 Jul 2021 23:28:10 +1200 Subject: [PATCH 3/3] trigger CI