Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions polkadot/node/core/approval-voting/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,8 @@ pub(crate) mod tests {
use polkadot_node_subsystem_test_helpers::make_subsystem_context;
use polkadot_node_subsystem_util::database::Database;
use polkadot_primitives::{
node_features::FeatureIndex, Id as ParaId, IndexedVec, MutateDescriptorV2, NodeFeatures,
SessionInfo, ValidatorId, ValidatorIndex,
node_features::FeatureIndex, ApprovalVotingParams, Id as ParaId, IndexedVec,
MutateDescriptorV2, NodeFeatures, SessionInfo, ValidatorId, ValidatorIndex,
};
use polkadot_primitives_test_helpers::{dummy_candidate_receipt_v2, dummy_hash};
use schnellru::{ByLength, LruMap};
Expand Down Expand Up @@ -887,6 +887,15 @@ pub(crate) mod tests {
si_tx.send(Ok(NodeFeatures::repeat(enable_v2, FeatureIndex::EnableAssignmentsV2 as usize + 1))).unwrap();
}
);

assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(_, RuntimeApiRequest::ApprovalVotingParams(_, si_tx), )
) => {
si_tx.send(Ok(ApprovalVotingParams::default())).unwrap();
}
);
});

futures::executor::block_on(futures::future::join(test_fut, aux_fut));
Expand Down Expand Up @@ -1014,6 +1023,15 @@ pub(crate) mod tests {
si_tx.send(Ok(NodeFeatures::EMPTY)).unwrap();
}
);

assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(_, RuntimeApiRequest::ApprovalVotingParams(_, si_tx), )
) => {
si_tx.send(Ok(ApprovalVotingParams::default())).unwrap();
}
);
});

futures::executor::block_on(futures::future::join(test_fut, aux_fut));
Expand Down Expand Up @@ -1244,6 +1262,15 @@ pub(crate) mod tests {
si_tx.send(Ok(NodeFeatures::EMPTY)).unwrap();
}
);

assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(_, RuntimeApiRequest::ApprovalVotingParams(_, si_tx), )
) => {
si_tx.send(Ok(ApprovalVotingParams::default())).unwrap();
}
);
});

futures::executor::block_on(futures::future::join(test_fut, aux_fut));
Expand Down Expand Up @@ -1459,6 +1486,15 @@ pub(crate) mod tests {
}
);

assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(_, RuntimeApiRequest::ApprovalVotingParams(_, si_tx), )
) => {
si_tx.send(Ok(ApprovalVotingParams::default())).unwrap();
}
);

assert_matches!(
handle.recv().await,
AllMessages::ApprovalDistribution(ApprovalDistributionMessage::NewBlocks(
Expand Down
56 changes: 6 additions & 50 deletions polkadot/node/core/approval-voting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ use polkadot_node_subsystem_util::{
TimeoutExt,
};
use polkadot_primitives::{
ApprovalVoteMultipleCandidates, ApprovalVotingParams, BlockNumber, CandidateHash,
CandidateIndex, CandidateReceiptV2 as CandidateReceipt, CoreIndex, GroupIndex, Hash,
SessionIndex, SessionInfo, ValidatorId, ValidatorIndex, ValidatorPair, ValidatorSignature,
ApprovalVoteMultipleCandidates, BlockNumber, CandidateHash, CandidateIndex,
CandidateReceiptV2 as CandidateReceipt, CoreIndex, GroupIndex, Hash, SessionIndex, SessionInfo,
ValidatorId, ValidatorIndex, ValidatorPair, ValidatorSignature,
};
use sc_keystore::LocalKeystore;
use sp_application_crypto::Pair;
Expand Down Expand Up @@ -1019,51 +1019,6 @@ impl State {
}
}

// Returns the approval voting params from the RuntimeApi.
async fn get_approval_voting_params_or_default<Sender: SubsystemSender<RuntimeApiMessage>>(
&self,
sender: &mut Sender,
session_index: SessionIndex,
block_hash: Hash,
) -> Option<ApprovalVotingParams> {
let (s_tx, s_rx) = oneshot::channel();

sender
.send_message(RuntimeApiMessage::Request(
block_hash,
RuntimeApiRequest::ApprovalVotingParams(session_index, s_tx),
))
.await;

match s_rx.await {
Ok(Ok(params)) => {
gum::trace!(
target: LOG_TARGET,
approval_voting_params = ?params,
session = ?session_index,
"Using the following subsystem params"
);
Some(params)
},
Ok(Err(err)) => {
gum::debug!(
target: LOG_TARGET,
?err,
"Could not request approval voting params from runtime"
);
None
},
Err(err) => {
gum::debug!(
target: LOG_TARGET,
?err,
"Could not request approval voting params from runtime"
);
None
},
}
}

fn mark_begining_of_gathering_assignments(
&mut self,
block_number: BlockNumber,
Expand Down Expand Up @@ -3828,9 +3783,10 @@ async fn maybe_create_signature<
},
};

let approval_params = state
.get_approval_voting_params_or_default(sender, block_entry.session(), block_hash)
let approval_params = session_info_provider
.get_session_info_by_index(sender, block_hash, block_entry.session())
.await
.map(|info| info.approval_voting_params)
.unwrap_or_default();

gum::trace!(
Expand Down
Loading
Loading