mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 09:21:05 +00:00
Dispute Coordinator: Batch queries (#3459)
* disputes: Allow batch queries in dispute-coordinator This commit moves to batch queries when responding to QueryCandidateVotes messages. This simplifies the code in the provisioner and dispute-coordinator by no longer requiring to make use of a FuturesOrdered when awaiting multiple quries. Instead, the provisioner need only request the batch itself. * node/approval-voting: Address Feedback to fail on query element missing. * Address feedback * Fix implementer's guide
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
//! # Sending and receiving of `DisputeRequest`s.
|
||||
//!
|
||||
//! This subsystem essentially consists of two parts:
|
||||
@@ -136,7 +135,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<AD> DisputeDistributionSubsystem<AD>
|
||||
impl<AD> DisputeDistributionSubsystem<AD>
|
||||
where
|
||||
AD: AuthorityDiscovery + Clone,
|
||||
{
|
||||
|
||||
@@ -352,11 +352,12 @@ async fn get_candidate_votes<Context: SubsystemContext>(
|
||||
let (tx, rx) = oneshot::channel();
|
||||
ctx.send_message(AllMessages::DisputeCoordinator(
|
||||
DisputeCoordinatorMessage::QueryCandidateVotes(
|
||||
session_index,
|
||||
candidate_hash,
|
||||
vec![(session_index, candidate_hash)],
|
||||
tx
|
||||
)
|
||||
))
|
||||
.await;
|
||||
rx.await.map_err(|_| NonFatal::AskCandidateVotesCanceled)
|
||||
rx.await
|
||||
.map(|v| v.get(0).map(|inner| inner.to_owned().2))
|
||||
.map_err(|_| NonFatal::AskCandidateVotesCanceled)
|
||||
}
|
||||
|
||||
@@ -151,9 +151,9 @@ fn received_request_triggers_import() {
|
||||
message.clone().into(),
|
||||
ImportStatementsResult::InvalidImport,
|
||||
true,
|
||||
move |handle, req_tx, message|
|
||||
move |handle, req_tx, message|
|
||||
nested_network_dispute_request(
|
||||
handle,
|
||||
handle,
|
||||
req_tx,
|
||||
MOCK_AUTHORITY_DISCOVERY.get_peer_id_by_authority(Sr25519Keyring::Bob),
|
||||
message.clone().into(),
|
||||
@@ -226,8 +226,8 @@ fn received_request_triggers_import() {
|
||||
|
||||
// But should work fine for Bob:
|
||||
nested_network_dispute_request(
|
||||
&mut handle,
|
||||
&mut req_tx,
|
||||
&mut handle,
|
||||
&mut req_tx,
|
||||
MOCK_AUTHORITY_DISCOVERY.get_peer_id_by_authority(Sr25519Keyring::Bob),
|
||||
message.clone().into(),
|
||||
ImportStatementsResult::ValidImport,
|
||||
@@ -258,15 +258,15 @@ fn disputes_are_recovered_at_startup() {
|
||||
handle.recv().await,
|
||||
AllMessages::DisputeCoordinator(
|
||||
DisputeCoordinatorMessage::QueryCandidateVotes(
|
||||
session_index,
|
||||
candidate_hash,
|
||||
query,
|
||||
tx,
|
||||
)
|
||||
) => {
|
||||
let (session_index, candidate_hash) = query.get(0).unwrap().clone();
|
||||
assert_eq!(session_index, MOCK_SESSION_INDEX);
|
||||
assert_eq!(candidate_hash, candidate.hash());
|
||||
let unchecked: UncheckedDisputeMessage = message.into();
|
||||
tx.send(Some(CandidateVotes {
|
||||
tx.send(vec![(session_index, candidate_hash, CandidateVotes {
|
||||
candidate_receipt: candidate,
|
||||
valid: vec![(
|
||||
unchecked.valid_vote.kind,
|
||||
@@ -278,7 +278,7 @@ fn disputes_are_recovered_at_startup() {
|
||||
unchecked.invalid_vote.validator_index,
|
||||
unchecked.invalid_vote.signature
|
||||
)],
|
||||
}))
|
||||
})])
|
||||
.expect("Receiver should stay alive.");
|
||||
}
|
||||
);
|
||||
@@ -473,7 +473,7 @@ async fn send_network_dispute_request(
|
||||
) -> oneshot::Receiver<sc_network::config::OutgoingResponse> {
|
||||
let (pending_response, rx_response) = oneshot::channel();
|
||||
let req = sc_network::config::IncomingRequest {
|
||||
peer,
|
||||
peer,
|
||||
payload: message.encode(),
|
||||
pending_response,
|
||||
};
|
||||
@@ -492,7 +492,7 @@ async fn nested_network_dispute_request<'a, F, O>(
|
||||
import_result: ImportStatementsResult,
|
||||
need_session_info: bool,
|
||||
inner: F,
|
||||
)
|
||||
)
|
||||
where
|
||||
F: FnOnce(
|
||||
&'a mut TestSubsystemContextHandle<DisputeDistributionMessage>,
|
||||
@@ -539,7 +539,7 @@ async fn nested_network_dispute_request<'a, F, O>(
|
||||
pending_confirmation
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// Do the inner thing:
|
||||
inner(handle, req_tx, message).await;
|
||||
|
||||
@@ -558,7 +558,7 @@ async fn nested_network_dispute_request<'a, F, O>(
|
||||
match import_result {
|
||||
ImportStatementsResult::ValidImport => {
|
||||
let result = result.unwrap();
|
||||
let decoded =
|
||||
let decoded =
|
||||
<DisputeResponse as Decode>::decode(&mut result.as_slice()).unwrap();
|
||||
|
||||
assert!(decoded == DisputeResponse::Confirmed);
|
||||
|
||||
Reference in New Issue
Block a user