diff --git a/roadmap/implementers-guide/src/runtime/disputes.md b/roadmap/implementers-guide/src/runtime/disputes.md index 4fb70eb93d03..9ccf3a3923f8 100644 --- a/roadmap/implementers-guide/src/runtime/disputes.md +++ b/roadmap/implementers-guide/src/runtime/disputes.md @@ -101,7 +101,7 @@ Frozen: Option, 1. If there is a dispute under `(Sessionindex, CandidateHash)` with fewer than `byzantine_threshold + 1` participating validators, decrease `SpamSlots` by 1 for each validator in the `DisputeState`. 1. If there is a dispute under `(SessionIndex, CandidateHash)` that has concluded against the candidate, invoke `revert_and_freeze` with the stored block number. -* `could_be_invalid(SessionIndex, CandidateHash) -> bool`: Returns whether a candidate has a live dispute ongoing or a dispute which has already concluded in the negative. +* `concluded_invalid(SessionIndex, CandidateHash) -> bool`: Returns whether a candidate has already concluded a dispute in the negative. * `is_frozen()`: Load the value of `Frozen` from storage. Return true if `Some` and false if `None`. diff --git a/roadmap/implementers-guide/src/runtime/parainherent.md b/roadmap/implementers-guide/src/runtime/parainherent.md index ed4d6fe7d90b..cb5bb45d8d81 100644 --- a/roadmap/implementers-guide/src/runtime/parainherent.md +++ b/roadmap/implementers-guide/src/runtime/parainherent.md @@ -1,4 +1,4 @@ -# ParaInherent +# `ParaInherent` This module is responsible for providing all data given to the runtime by the block author to the various parachains modules. The entry-point is mandatory, in that it must be invoked exactly once within every block, and it is also "inherent", in that it is provided with no origin by the block author. The data within it carries its own authentication; i.e. the data takes the form of signed statements by validators. If any of the steps within fails, the entry-point is considered as having failed and the block will be invalid. @@ -26,7 +26,7 @@ Included: Option<()>, 1. Hash the parent header and make sure that it corresponds to the block hash of the parent (tracked by the `frame_system` FRAME module), 1. Invoke `Disputes::provide_multi_dispute_data`. 1. If `Disputes::is_frozen`, return and set `Included` to `Some(())`. - 1. If there are any created disputes from the current session, invoke `Inclusion::collect_disputed` with the disputed candidates. Annotate each returned core with `FreedReason::Concluded`. + 1. If there are any concluded disputes from the current session, invoke `Inclusion::collect_disputed` with the disputed candidates. Annotate each returned core with `FreedReason::Concluded`. 1. The `Bitfields` are first forwarded to the `Inclusion::process_bitfields` routine, returning a set of freed cores. Provide the number of availability cores (`Scheduler::availability_cores().len()`) as the expected number of bits and a `Scheduler::core_para` as a core-lookup to the `process_bitfields` routine. Annotate each of these freed cores with `FreedReason::Concluded`. 1. For each freed candidate from the `Inclusion::process_bitfields` call, invoke `Disputes::note_included(current_session, candidate)`. 1. If `Scheduler::availability_timeout_predicate` is `Some`, invoke `Inclusion::collect_pending` using it and annotate each of those freed cores with `FreedReason::TimedOut`. @@ -34,7 +34,7 @@ Included: Option<()>, 1. Invoke `Scheduler::clear` 1. Invoke `Scheduler::schedule(freed_cores, System::current_block())` 1. Extract `parent_storage_root` from the parent header, - 1. If `Disputes::could_be_invalid(current_session, candidate)` is true for any of the `backed_candidates`, fail. + 1. If `Disputes::concluded_invalid(current_session, candidate)` is true for any of the `backed_candidates`, fail. 1. Invoke the `Inclusion::process_candidates` routine with the parameters `(parent_storage_root, backed_candidates, Scheduler::scheduled(), Scheduler::group_validators)`. 1. Call `Scheduler::occupied` using the return value of the `Inclusion::process_candidates` call above, first sorting the list of assigned core indices. 1. Call the `Ump::process_pending_upward_messages` routine to execute all messages in upward dispatch queues. diff --git a/runtime/parachains/src/paras_inherent.rs b/runtime/parachains/src/paras_inherent.rs index 9ac8e0141542..ea480ad7c96a 100644 --- a/runtime/parachains/src/paras_inherent.rs +++ b/runtime/parachains/src/paras_inherent.rs @@ -174,24 +174,27 @@ pub mod pallet { // Handle disputes logic. let current_session = >::session_index(); let freed_disputed: Vec<(_, FreedReason)> = { - let fresh_disputes = T::DisputesHandler::provide_multi_dispute_data(disputes)?; + let new_current_dispute_sets: Vec<_> = disputes + .iter() + .filter(|s| s.session == current_session) + .map(|s| (s.session, s.candidate_hash)) + .collect(); + + let _ = T::DisputesHandler::provide_multi_dispute_data(disputes)?; if T::DisputesHandler::is_frozen() { // The relay chain we are currently on is invalid. Proceed no further on parachains. Included::::set(Some(())); return Ok(Some(MINIMAL_INCLUSION_INHERENT_WEIGHT).into()) } - let any_current_session_disputes = - fresh_disputes.iter().any(|(s, _)| s == ¤t_session); - - if any_current_session_disputes { - let current_session_disputes: Vec<_> = fresh_disputes + if !new_current_dispute_sets.is_empty() { + let concluded_invalid_disputes: Vec<_> = new_current_dispute_sets .iter() - .filter(|(s, _)| s == ¤t_session) + .filter(|(s, c)| T::DisputesHandler::concluded_invalid(*s, *c)) .map(|(_, c)| *c) .collect(); - >::collect_disputed(current_session_disputes) + >::collect_disputed(concluded_invalid_disputes) .into_iter() .map(|core| (core, FreedReason::Concluded)) .collect()