diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index bf918c61724f..a0e4ff9e7a96 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -277,7 +277,7 @@ pub trait DisputesHandler { /// Handle sets of dispute statements corresponding to 0 or more candidates. /// Returns a vector of freshly created disputes. fn process_checked_multi_dispute_data( - statement_sets: CheckedMultiDisputeStatementSet, + statement_sets: &CheckedMultiDisputeStatementSet, ) -> Result, DispatchError>; /// Note that the given candidate has been included. @@ -325,7 +325,7 @@ impl DisputesHandler for () { } fn process_checked_multi_dispute_data( - _statement_sets: CheckedMultiDisputeStatementSet, + _statement_sets: &CheckedMultiDisputeStatementSet, ) -> Result, DispatchError> { Ok(Vec::new()) } @@ -379,7 +379,7 @@ where } fn process_checked_multi_dispute_data( - statement_sets: CheckedMultiDisputeStatementSet, + statement_sets: &CheckedMultiDisputeStatementSet, ) -> Result, DispatchError> { pallet::Pallet::::process_checked_multi_dispute_data(statement_sets) } @@ -983,14 +983,14 @@ impl Pallet { /// and to fail the extrinsic on error. As invalid inherents are not allowed, the dirty state /// is not committed. pub(crate) fn process_checked_multi_dispute_data( - statement_sets: CheckedMultiDisputeStatementSet, + statement_sets: &CheckedMultiDisputeStatementSet, ) -> Result, DispatchError> { let config = >::config(); let mut fresh = Vec::with_capacity(statement_sets.len()); for statement_set in statement_sets { let dispute_target = { - let statement_set: &DisputeStatementSet = statement_set.as_ref(); + let statement_set = statement_set.as_ref(); (statement_set.session, statement_set.candidate_hash) }; if Self::process_checked_dispute_data( @@ -1126,7 +1126,7 @@ impl Pallet { /// Fails if the dispute data is invalid. Returns a Boolean indicating whether the /// dispute is fresh. fn process_checked_dispute_data( - set: CheckedDisputeStatementSet, + set: &CheckedDisputeStatementSet, dispute_post_conclusion_acceptance_period: T::BlockNumber, ) -> Result { // Dispute statement sets on any dispute which concluded diff --git a/runtime/parachains/src/disputes/tests.rs b/runtime/parachains/src/disputes/tests.rs index 8e9e0097f703..b12814fd72be 100644 --- a/runtime/parachains/src/disputes/tests.rs +++ b/runtime/parachains/src/disputes/tests.rs @@ -431,7 +431,7 @@ fn test_dispute_timeout() { let stmts = filter_dispute_set(stmts); assert_ok!( - Pallet::::process_checked_multi_dispute_data(stmts), + Pallet::::process_checked_multi_dispute_data(&stmts), vec![(9, candidate_hash.clone())], ); @@ -579,7 +579,7 @@ fn test_provide_multi_dispute_is_providing() { assert_ok!( Pallet::::process_checked_multi_dispute_data( - stmts + &stmts .into_iter() .map(CheckedDisputeStatementSet::unchecked_from_unchecked) .collect() @@ -644,7 +644,7 @@ fn test_disputes_with_missing_backing_votes_are_rejected() { }]; assert!(Pallet::::process_checked_multi_dispute_data( - stmts + &stmts .into_iter() .map(CheckedDisputeStatementSet::unchecked_from_unchecked) .collect() @@ -714,7 +714,7 @@ fn test_freeze_on_note_included() { ], }]; assert!(Pallet::::process_checked_multi_dispute_data( - stmts + &stmts .into_iter() .map(CheckedDisputeStatementSet::unchecked_from_unchecked) .collect() @@ -789,7 +789,7 @@ fn test_freeze_provided_against_supermajority_for_included() { Pallet::::note_included(3, candidate_hash.clone(), 3); assert!(Pallet::::process_checked_multi_dispute_data( - stmts + &stmts .into_iter() .map(CheckedDisputeStatementSet::unchecked_from_unchecked) .collect() @@ -891,7 +891,7 @@ mod unconfirmed_disputes { let stmts = filter_dispute_set(stmts); // Not confirmed => should be filtered out - assert_ok!(Pallet::::process_checked_multi_dispute_data(stmts), vec![],); + assert_ok!(Pallet::::process_checked_multi_dispute_data(&stmts), vec![],); }); } @@ -903,7 +903,7 @@ mod unconfirmed_disputes { let stmts = vec![CheckedDisputeStatementSet::unchecked_from_unchecked(stmts)]; assert_matches!( - Pallet::::process_checked_multi_dispute_data(stmts), + Pallet::::process_checked_multi_dispute_data(&stmts), Err(DispatchError::Module(ModuleError{index: _, error: _, message})) => assert_eq!(message, Some("UnconfirmedDispute")) ); @@ -1011,7 +1011,7 @@ fn test_provide_multi_dispute_success_and_other() { let stmts = filter_dispute_set(stmts); assert_ok!( - Pallet::::process_checked_multi_dispute_data(stmts), + Pallet::::process_checked_multi_dispute_data(&stmts), vec![(3, candidate_hash.clone())], ); @@ -1076,7 +1076,7 @@ fn test_provide_multi_dispute_success_and_other() { let stmts = filter_dispute_set(stmts); assert_ok!( - Pallet::::process_checked_multi_dispute_data(stmts), + Pallet::::process_checked_multi_dispute_data(&stmts), vec![(5, candidate_hash.clone())], ); @@ -1098,7 +1098,7 @@ fn test_provide_multi_dispute_success_and_other() { )], }]; let stmts = filter_dispute_set(stmts); - assert_ok!(Pallet::::process_checked_multi_dispute_data(stmts), vec![]); + assert_ok!(Pallet::::process_checked_multi_dispute_data(&stmts), vec![]); let stmts = vec![ // 0, 4, and 5 vote against 5 @@ -1177,7 +1177,7 @@ fn test_provide_multi_dispute_success_and_other() { }, ]; let stmts = filter_dispute_set(stmts); - assert_ok!(Pallet::::process_checked_multi_dispute_data(stmts), vec![]); + assert_ok!(Pallet::::process_checked_multi_dispute_data(&stmts), vec![]); assert_eq!( Pallet::::disputes(), @@ -1386,7 +1386,7 @@ fn test_punish_post_conclusion() { let stmts = filter_dispute_set(stmts); assert_ok!( - Pallet::::process_checked_multi_dispute_data(stmts), + Pallet::::process_checked_multi_dispute_data(&stmts), vec![(session, candidate_hash)], ); @@ -1429,7 +1429,7 @@ fn test_punish_post_conclusion() { }]; let stmts = filter_dispute_set(stmts); - assert_ok!(Pallet::::process_checked_multi_dispute_data(stmts), vec![],); + assert_ok!(Pallet::::process_checked_multi_dispute_data(&stmts), vec![],); // Ensure punishment for is called assert_eq!( diff --git a/runtime/parachains/src/paras_inherent/mod.rs b/runtime/parachains/src/paras_inherent/mod.rs index db9caca49d1b..c2dff1e16487 100644 --- a/runtime/parachains/src/paras_inherent/mod.rs +++ b/runtime/parachains/src/paras_inherent/mod.rs @@ -412,8 +412,7 @@ impl Pallet { // Note that `process_checked_multi_dispute_data` will iterate and import each // dispute; so the input here must be reasonably bounded, // which is guaranteed by the checks and weight limitation above. - let _ = - T::DisputesHandler::process_checked_multi_dispute_data(checked_disputes.clone())?; + let _ = T::DisputesHandler::process_checked_multi_dispute_data(&checked_disputes)?; METRICS.on_disputes_imported(checked_disputes.len() as u64); if T::DisputesHandler::is_frozen() { @@ -625,13 +624,11 @@ impl Pallet { // we don't care about fresh or not disputes // this writes them to storage, so let's query it via those means // if this fails for whatever reason, that's ok - let _ = T::DisputesHandler::process_checked_multi_dispute_data( - checked_disputes_sets.clone(), - ) - .map_err(|e| { - log::warn!(target: LOG_TARGET, "MultiDisputesData failed to update: {:?}", e); - e - }); + let _ = T::DisputesHandler::process_checked_multi_dispute_data(&checked_disputes_sets) + .map_err(|e| { + log::warn!(target: LOG_TARGET, "MultiDisputesData failed to update: {:?}", e); + e + }); // Contains the disputes that are concluded in the current session only, // since these are the only ones that are relevant for the occupied cores