From e0752b19883ffc97682bb5fc0305828ab33d413b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Sun, 4 Jun 2023 23:15:16 +0200 Subject: [PATCH] frame_system::remark: Allow any kind of origin (#14260) * frame_system::remark: Allow any kind of origin There should be no downside in allowing any kind of origin for `remark`. * Fix tests --- frame/alliance/src/tests.rs | 2 +- frame/collective/src/benchmarking.rs | 8 ++++---- frame/system/src/lib.rs | 5 ++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/frame/alliance/src/tests.rs b/frame/alliance/src/tests.rs index de7cda4710fc7..098fd86bbae1e 100644 --- a/frame/alliance/src/tests.rs +++ b/frame/alliance/src/tests.rs @@ -299,7 +299,7 @@ fn close_works() { })), record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Executed { proposal_hash: hash, - result: Err(DispatchError::BadOrigin), + result: Ok(()), })) ] ); diff --git a/frame/collective/src/benchmarking.rs b/frame/collective/src/benchmarking.rs index bcd203c3894a3..8a4495ef4095b 100644 --- a/frame/collective/src/benchmarking.rs +++ b/frame/collective/src/benchmarking.rs @@ -131,7 +131,7 @@ benchmarks_instance_pallet! { let proposal_hash = T::Hashing::hash_of(&proposal); // Note that execution fails due to mis-matched origin assert_last_event::( - Event::MemberExecuted { proposal_hash, result: Err(DispatchError::BadOrigin) }.into() + Event::MemberExecuted { proposal_hash, result: Ok(()) }.into() ); } @@ -162,7 +162,7 @@ benchmarks_instance_pallet! { let proposal_hash = T::Hashing::hash_of(&proposal); // Note that execution fails due to mis-matched origin assert_last_event::( - Event::Executed { proposal_hash, result: Err(DispatchError::BadOrigin) }.into() + Event::Executed { proposal_hash, result: Ok(()) }.into() ); } @@ -441,7 +441,7 @@ benchmarks_instance_pallet! { verify { // The last proposal is removed. assert_eq!(Collective::::proposals().len(), (p - 1) as usize); - assert_last_event::(Event::Executed { proposal_hash: last_hash, result: Err(DispatchError::BadOrigin) }.into()); + assert_last_event::(Event::Executed { proposal_hash: last_hash, result: Ok(()) }.into()); } close_disapproved { @@ -595,7 +595,7 @@ benchmarks_instance_pallet! { }: close(SystemOrigin::Signed(caller), last_hash, p - 1, Weight::MAX, bytes_in_storage) verify { assert_eq!(Collective::::proposals().len(), (p - 1) as usize); - assert_last_event::(Event::Executed { proposal_hash: last_hash, result: Err(DispatchError::BadOrigin) }.into()); + assert_last_event::(Event::Executed { proposal_hash: last_hash, result: Ok(()) }.into()); } disapprove_proposal { diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 79cdcf22f55c7..a48a1e459f32a 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -414,11 +414,10 @@ pub mod pallet { impl Pallet { /// Make some on-chain remark. /// - /// - `O(1)` + /// Can be executed by every `origin`. #[pallet::call_index(0)] #[pallet::weight(T::SystemWeightInfo::remark(_remark.len() as u32))] - pub fn remark(origin: OriginFor, _remark: Vec) -> DispatchResultWithPostInfo { - ensure_signed_or_root(origin)?; + pub fn remark(_origin: OriginFor, _remark: Vec) -> DispatchResultWithPostInfo { Ok(().into()) }