style: Migrate to stable-only rustfmt configuration
- Remove nightly-only features from .rustfmt.toml and vendor/ss58-registry/rustfmt.toml - Removed features: imports_granularity, wrap_comments, comment_width, reorder_impl_items, spaces_around_ranges, binop_separator, match_arm_blocks, trailing_semicolon, trailing_comma - Format all 898 affected files with stable rustfmt - Ensures long-term reliability without nightly toolchain dependency
This commit is contained in:
@@ -419,8 +419,8 @@ impl Knowledge {
|
||||
// we need to share the same `MessageSubject` with the followup approval candidate index.
|
||||
if kind == MessageKind::Assignment && success && message.1.count_ones() > 1 {
|
||||
for candidate_index in message.1.iter_ones() {
|
||||
success = success &&
|
||||
self.insert(
|
||||
success = success
|
||||
&& self.insert(
|
||||
MessageSubject(
|
||||
message.0,
|
||||
vec![candidate_index as u32].try_into().expect("Non-empty vec; qed"),
|
||||
@@ -1300,8 +1300,8 @@ impl State {
|
||||
|
||||
let age = max_age.saturating_sub(min_age);
|
||||
|
||||
aggression_config.should_trigger_aggression(age) &&
|
||||
topology.map(|topology| topology.is_validator(&peer)).unwrap_or(false)
|
||||
aggression_config.should_trigger_aggression(age)
|
||||
&& topology.map(|topology| topology.is_validator(&peer)).unwrap_or(false)
|
||||
}
|
||||
|
||||
async fn import_and_circulate_assignment<A, N, RA, R>(
|
||||
@@ -2282,11 +2282,11 @@ impl State {
|
||||
})
|
||||
.unwrap_or(true);
|
||||
|
||||
if resend == Resend::Yes &&
|
||||
config.resend_unfinalized_period.as_ref().map_or(false, |p| {
|
||||
block_age > 0 &&
|
||||
block_age % p == 0 && diff_from_min_age == 0 &&
|
||||
can_resend_at_this_age
|
||||
if resend == Resend::Yes
|
||||
&& config.resend_unfinalized_period.as_ref().map_or(false, |p| {
|
||||
block_age > 0
|
||||
&& block_age % p == 0 && diff_from_min_age == 0
|
||||
&& can_resend_at_this_age
|
||||
}) {
|
||||
// Retry sending to all peers.
|
||||
for (_, knowledge) in block_entry.known_by.iter_mut() {
|
||||
@@ -2372,8 +2372,9 @@ impl State {
|
||||
// We assume `candidate_bitfield` length for the core bitfield and we just check
|
||||
// against `MAX_BITFIELD_SIZE` later.
|
||||
AssignmentCertKindV2::RelayVRFModulo { .. } => candidate_bitfield.len(),
|
||||
AssignmentCertKindV2::RelayVRFModuloCompact { core_bitfield } =>
|
||||
core_bitfield.len(),
|
||||
AssignmentCertKindV2::RelayVRFModuloCompact { core_bitfield } => {
|
||||
core_bitfield.len()
|
||||
},
|
||||
};
|
||||
|
||||
let candidate_bitfield_bits = candidate_bitfield.len();
|
||||
@@ -2411,8 +2412,8 @@ impl State {
|
||||
let mut sanitized_approvals = Vec::new();
|
||||
for approval in approval.into_iter() {
|
||||
let has_no_approved_candidates = approval.candidate_indices.first_one().is_none();
|
||||
if approval.candidate_indices.len() as usize > MAX_BITFIELD_SIZE ||
|
||||
has_no_approved_candidates
|
||||
if approval.candidate_indices.len() as usize > MAX_BITFIELD_SIZE
|
||||
|| has_no_approved_candidates
|
||||
{
|
||||
// Punish the peer for the invalid message.
|
||||
modify_reputation(
|
||||
@@ -2687,7 +2688,7 @@ impl ApprovalDistribution {
|
||||
session_info_provider: &mut RuntimeInfo,
|
||||
) -> bool {
|
||||
match message {
|
||||
FromOrchestra::Communication { msg } =>
|
||||
FromOrchestra::Communication { msg } => {
|
||||
Self::handle_incoming(
|
||||
approval_voting_sender,
|
||||
network_sender,
|
||||
@@ -2700,7 +2701,8 @@ impl ApprovalDistribution {
|
||||
self.clock.as_ref(),
|
||||
session_info_provider,
|
||||
)
|
||||
.await,
|
||||
.await
|
||||
},
|
||||
FromOrchestra::Signal(OverseerSignal::ActiveLeaves(_update)) => {
|
||||
gum::trace!(target: LOG_TARGET, "active leaves signal (ignored)");
|
||||
// the relay chain blocks relevant to the approval subsystems
|
||||
@@ -2849,9 +2851,9 @@ const fn ensure_size_not_zero(size: usize) -> usize {
|
||||
/// assignments we send in a single message to peers. Exceeding `MAX_NOTIFICATION_SIZE` will violate
|
||||
/// the protocol configuration.
|
||||
pub const MAX_ASSIGNMENT_BATCH_SIZE: usize = ensure_size_not_zero(
|
||||
MAX_NOTIFICATION_SIZE as usize /
|
||||
std::mem::size_of::<(IndirectAssignmentCertV2, CandidateIndex)>() /
|
||||
3,
|
||||
MAX_NOTIFICATION_SIZE as usize
|
||||
/ std::mem::size_of::<(IndirectAssignmentCertV2, CandidateIndex)>()
|
||||
/ 3,
|
||||
);
|
||||
|
||||
/// The maximum amount of approvals per batch is 33% of maximum allowed by protocol.
|
||||
|
||||
@@ -106,17 +106,17 @@ pub fn log_error(
|
||||
Ok(()) => Ok(()),
|
||||
Err(jfyi) => {
|
||||
match jfyi {
|
||||
JfyiError::UnexpectedPoV |
|
||||
JfyiError::InvalidValidatorIndex |
|
||||
JfyiError::NoSuchCachedSession { .. } |
|
||||
JfyiError::QueryAvailableDataResponseChannel(_) |
|
||||
JfyiError::QueryChunkResponseChannel(_) |
|
||||
JfyiError::FailedNodeFeatures(_) |
|
||||
JfyiError::ErasureCoding(_) => gum::warn!(target: LOG_TARGET, error = %jfyi, ctx),
|
||||
JfyiError::FetchPoV(_) |
|
||||
JfyiError::SendResponse |
|
||||
JfyiError::NoSuchPoV |
|
||||
JfyiError::Runtime(_) => {
|
||||
JfyiError::UnexpectedPoV
|
||||
| JfyiError::InvalidValidatorIndex
|
||||
| JfyiError::NoSuchCachedSession { .. }
|
||||
| JfyiError::QueryAvailableDataResponseChannel(_)
|
||||
| JfyiError::QueryChunkResponseChannel(_)
|
||||
| JfyiError::FailedNodeFeatures(_)
|
||||
| JfyiError::ErasureCoding(_) => gum::warn!(target: LOG_TARGET, error = %jfyi, ctx),
|
||||
JfyiError::FetchPoV(_)
|
||||
| JfyiError::SendResponse
|
||||
| JfyiError::NoSuchPoV
|
||||
| JfyiError::Runtime(_) => {
|
||||
gum::warn_if_frequent!(freq: warn_freq, max_rate: gum::Times::PerHour(100), target: LOG_TARGET, error = ?jfyi, ctx)
|
||||
},
|
||||
}
|
||||
|
||||
@@ -143,8 +143,9 @@ impl AvailabilityDistributionSubsystem {
|
||||
|
||||
// Handle task messages sending:
|
||||
let message = match action {
|
||||
Either::Left(subsystem_msg) =>
|
||||
subsystem_msg.map_err(|e| FatalError::IncomingMessageChannel(e))?,
|
||||
Either::Left(subsystem_msg) => {
|
||||
subsystem_msg.map_err(|e| FatalError::IncomingMessageChannel(e))?
|
||||
},
|
||||
Either::Right(from_task) => {
|
||||
let from_task = from_task.ok_or(FatalError::RequesterExhausted)?;
|
||||
ctx.send_message(from_task).await;
|
||||
|
||||
@@ -369,7 +369,7 @@ impl RunningTask {
|
||||
|
||||
match response_recv.await {
|
||||
Ok((bytes, protocol)) => match protocol {
|
||||
_ if protocol == self.req_v2_protocol_name =>
|
||||
_ if protocol == self.req_v2_protocol_name => {
|
||||
match v2::ChunkFetchingResponse::decode(&mut &bytes[..]) {
|
||||
Ok(chunk_response) => Ok(Option::<ErasureChunk>::from(chunk_response)),
|
||||
Err(e) => {
|
||||
@@ -386,8 +386,9 @@ impl RunningTask {
|
||||
);
|
||||
Err(TaskError::PeerError)
|
||||
},
|
||||
},
|
||||
_ if protocol == self.req_v1_protocol_name =>
|
||||
}
|
||||
},
|
||||
_ if protocol == self.req_v1_protocol_name => {
|
||||
match v1::ChunkFetchingResponse::decode(&mut &bytes[..]) {
|
||||
Ok(chunk_response) => Ok(Option::<ChunkResponse>::from(chunk_response)
|
||||
.map(|c| c.recombine_into_chunk(&self.request.into()))),
|
||||
@@ -405,7 +406,8 @@ impl RunningTask {
|
||||
);
|
||||
Err(TaskError::PeerError)
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
gum::warn!(
|
||||
target: LOG_TARGET,
|
||||
|
||||
@@ -296,15 +296,15 @@ impl TestRun {
|
||||
self.chunk_responses.get(&req.peer).ok_or(network::RequestFailure::Refused);
|
||||
|
||||
if let Ok((resp, protocol)) = response {
|
||||
let chunk = if protocol ==
|
||||
&self.req_protocol_names.get_name(Protocol::ChunkFetchingV1)
|
||||
let chunk = if protocol
|
||||
== &self.req_protocol_names.get_name(Protocol::ChunkFetchingV1)
|
||||
{
|
||||
Into::<Option<v1::ChunkResponse>>::into(
|
||||
v1::ChunkFetchingResponse::decode(&mut &resp[..]).unwrap(),
|
||||
)
|
||||
.map(|c| c.chunk)
|
||||
} else if protocol ==
|
||||
&self.req_protocol_names.get_name(Protocol::ChunkFetchingV2)
|
||||
} else if protocol
|
||||
== &self.req_protocol_names.get_name(Protocol::ChunkFetchingV2)
|
||||
{
|
||||
Into::<Option<ErasureChunk>>::into(
|
||||
v2::ChunkFetchingResponse::decode(&mut &resp[..]).unwrap(),
|
||||
|
||||
@@ -94,8 +94,8 @@ fn check_basic(#[case] node_features: NodeFeatures, #[case] chunk_resp_protocol:
|
||||
let state =
|
||||
TestState::new(node_features.clone(), req_protocol_names.clone(), chunk_resp_protocol);
|
||||
|
||||
if node_features == node_features_with_mapping_enabled() &&
|
||||
chunk_resp_protocol == Protocol::ChunkFetchingV1
|
||||
if node_features == node_features_with_mapping_enabled()
|
||||
&& chunk_resp_protocol == Protocol::ChunkFetchingV1
|
||||
{
|
||||
// For this specific case, chunk fetching is not possible, because the ValidatorIndex is not
|
||||
// equal to the ChunkIndex and the peer does not send back the actual ChunkIndex.
|
||||
@@ -128,8 +128,8 @@ fn check_fetch_tries_all(
|
||||
v.push(None);
|
||||
}
|
||||
|
||||
if node_features == node_features_with_mapping_enabled() &&
|
||||
chunk_resp_protocol == Protocol::ChunkFetchingV1
|
||||
if node_features == node_features_with_mapping_enabled()
|
||||
&& chunk_resp_protocol == Protocol::ChunkFetchingV1
|
||||
{
|
||||
// For this specific case, chunk fetching is not possible, because the ValidatorIndex is not
|
||||
// equal to the ChunkIndex and the peer does not send back the actual ChunkIndex.
|
||||
@@ -186,8 +186,8 @@ fn check_fetch_retry(#[case] node_features: NodeFeatures, #[case] chunk_resp_pro
|
||||
v.push(None);
|
||||
}
|
||||
|
||||
if node_features == node_features_with_mapping_enabled() &&
|
||||
chunk_resp_protocol == Protocol::ChunkFetchingV1
|
||||
if node_features == node_features_with_mapping_enabled()
|
||||
&& chunk_resp_protocol == Protocol::ChunkFetchingV1
|
||||
{
|
||||
// For this specific case, chunk fetching is not possible, because the ValidatorIndex is not
|
||||
// equal to the ChunkIndex and the peer does not send back the actual ChunkIndex.
|
||||
|
||||
@@ -418,8 +418,8 @@ async fn handle_recover<Context>(
|
||||
let mut small_pov_size = true;
|
||||
|
||||
match recovery_strategy_kind {
|
||||
RecoveryStrategyKind::BackersFirstIfSizeLower(fetch_chunks_threshold) |
|
||||
RecoveryStrategyKind::BackersFirstIfSizeLowerThenSystematicChunks(
|
||||
RecoveryStrategyKind::BackersFirstIfSizeLower(fetch_chunks_threshold)
|
||||
| RecoveryStrategyKind::BackersFirstIfSizeLowerThenSystematicChunks(
|
||||
fetch_chunks_threshold,
|
||||
) => {
|
||||
// Get our own chunk size to get an estimate of the PoV size.
|
||||
@@ -448,16 +448,17 @@ async fn handle_recover<Context>(
|
||||
};
|
||||
|
||||
match (&recovery_strategy_kind, small_pov_size) {
|
||||
(RecoveryStrategyKind::BackersFirstAlways, _) |
|
||||
(RecoveryStrategyKind::BackersFirstIfSizeLower(_), true) |
|
||||
(
|
||||
(RecoveryStrategyKind::BackersFirstAlways, _)
|
||||
| (RecoveryStrategyKind::BackersFirstIfSizeLower(_), true)
|
||||
| (
|
||||
RecoveryStrategyKind::BackersFirstIfSizeLowerThenSystematicChunks(_),
|
||||
true,
|
||||
) |
|
||||
(RecoveryStrategyKind::BackersThenSystematicChunks, _) =>
|
||||
)
|
||||
| (RecoveryStrategyKind::BackersThenSystematicChunks, _) => {
|
||||
recovery_strategies.push_back(Box::new(FetchFull::new(
|
||||
FetchFullParams { validators: backing_validators.to_vec() },
|
||||
))),
|
||||
)))
|
||||
},
|
||||
_ => {},
|
||||
};
|
||||
|
||||
@@ -479,9 +480,9 @@ async fn handle_recover<Context>(
|
||||
if let Some(core_index) = maybe_core_index {
|
||||
if matches!(
|
||||
recovery_strategy_kind,
|
||||
RecoveryStrategyKind::BackersThenSystematicChunks |
|
||||
RecoveryStrategyKind::SystematicChunks |
|
||||
RecoveryStrategyKind::BackersFirstIfSizeLowerThenSystematicChunks(_)
|
||||
RecoveryStrategyKind::BackersThenSystematicChunks
|
||||
| RecoveryStrategyKind::SystematicChunks
|
||||
| RecoveryStrategyKind::BackersFirstIfSizeLowerThenSystematicChunks(_)
|
||||
) && chunk_mapping_enabled
|
||||
{
|
||||
let chunk_indices =
|
||||
@@ -507,8 +508,8 @@ async fn handle_recover<Context>(
|
||||
.into_iter()
|
||||
.filter(|(c_index, _)| {
|
||||
usize::try_from(c_index.0)
|
||||
.expect("usize is at least u32 bytes on all modern targets.") <
|
||||
systematic_threshold
|
||||
.expect("usize is at least u32 bytes on all modern targets.")
|
||||
< systematic_threshold
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ where
|
||||
let res = current_strategy.run(&mut self.state, &mut self.sender, &self.params).await;
|
||||
|
||||
match res {
|
||||
Err(RecoveryError::Unavailable) =>
|
||||
Err(RecoveryError::Unavailable) => {
|
||||
if self.strategies.front().is_some() {
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
@@ -167,11 +167,13 @@ where
|
||||
display_name
|
||||
);
|
||||
continue;
|
||||
},
|
||||
}
|
||||
},
|
||||
Err(err) => {
|
||||
match &err {
|
||||
RecoveryError::Invalid =>
|
||||
self.params.metrics.on_recovery_invalid(strategy_type),
|
||||
RecoveryError::Invalid => {
|
||||
self.params.metrics.on_recovery_invalid(strategy_type)
|
||||
},
|
||||
_ => self.params.metrics.on_recovery_failed(strategy_type),
|
||||
}
|
||||
return Err(err);
|
||||
|
||||
@@ -191,8 +191,8 @@ impl<Sender: overseer::AvailabilityRecoverySenderTrait> RecoveryStrategy<Sender>
|
||||
// No need to query the validators that have the chunks we already received or that we know
|
||||
// don't have the data from previous strategies.
|
||||
self.validators.retain(|v_index| {
|
||||
!state.received_chunks.values().any(|c| v_index == &c.validator_index) &&
|
||||
state.can_retry_request(
|
||||
!state.received_chunks.values().any(|c| v_index == &c.validator_index)
|
||||
&& state.can_retry_request(
|
||||
&(common_params.validator_authority_keys[v_index.0 as usize].clone(), *v_index),
|
||||
REGULAR_CHUNKS_REQ_RETRY_LIMIT,
|
||||
)
|
||||
@@ -279,8 +279,8 @@ impl<Sender: overseer::AvailabilityRecoverySenderTrait> RecoveryStrategy<Sender>
|
||||
in_flight_reqs,
|
||||
chunk_count,
|
||||
_systematic_chunk_count| {
|
||||
chunk_count >= common_params.threshold ||
|
||||
Self::is_unavailable(
|
||||
chunk_count >= common_params.threshold
|
||||
|| Self::is_unavailable(
|
||||
unrequested_validators,
|
||||
in_flight_reqs,
|
||||
chunk_count,
|
||||
|
||||
@@ -113,8 +113,9 @@ impl<Sender: overseer::AvailabilityRecoverySenderTrait> RecoveryStrategy<Sender>
|
||||
|
||||
reencode_rx.await.map_err(|_| RecoveryError::ChannelClosed)?
|
||||
},
|
||||
PostRecoveryCheck::PovHash =>
|
||||
(data.pov.hash() == common_params.pov_hash).then_some(data),
|
||||
PostRecoveryCheck::PovHash => {
|
||||
(data.pov.hash() == common_params.pov_hash).then_some(data)
|
||||
},
|
||||
};
|
||||
|
||||
match maybe_data {
|
||||
@@ -150,8 +151,9 @@ impl<Sender: overseer::AvailabilityRecoverySenderTrait> RecoveryStrategy<Sender>
|
||||
Err(e) => {
|
||||
match &e {
|
||||
RequestError::Canceled(_) => common_params.metrics.on_full_request_error(),
|
||||
RequestError::InvalidResponse(_) =>
|
||||
common_params.metrics.on_full_request_invalid(),
|
||||
RequestError::InvalidResponse(_) => {
|
||||
common_params.metrics.on_full_request_invalid()
|
||||
},
|
||||
RequestError::NetworkError(req_failure) => {
|
||||
if let RequestFailure::Network(OutboundFailure::Timeout) = req_failure {
|
||||
common_params.metrics.on_full_request_timeout();
|
||||
|
||||
@@ -385,10 +385,12 @@ impl State {
|
||||
Ok((bytes, protocol)) => {
|
||||
if v2_protocol_name == protocol {
|
||||
match req_res::v2::ChunkFetchingResponse::decode(&mut &bytes[..]) {
|
||||
Ok(req_res::v2::ChunkFetchingResponse::Chunk(chunk)) =>
|
||||
Ok((Some(chunk.into()), protocol)),
|
||||
Ok(req_res::v2::ChunkFetchingResponse::NoSuchChunk) =>
|
||||
Ok((None, protocol)),
|
||||
Ok(req_res::v2::ChunkFetchingResponse::Chunk(chunk)) => {
|
||||
Ok((Some(chunk.into()), protocol))
|
||||
},
|
||||
Ok(req_res::v2::ChunkFetchingResponse::NoSuchChunk) => {
|
||||
Ok((None, protocol))
|
||||
},
|
||||
Err(e) => Err(RequestError::InvalidResponse(e)),
|
||||
}
|
||||
} else if v1_protocol_name == protocol {
|
||||
@@ -413,8 +415,9 @@ impl State {
|
||||
Some(chunk.recombine_into_chunk(&raw_request_v1)),
|
||||
protocol,
|
||||
)),
|
||||
Ok(req_res::v1::ChunkFetchingResponse::NoSuchChunk) =>
|
||||
Ok((None, protocol)),
|
||||
Ok(req_res::v1::ChunkFetchingResponse::NoSuchChunk) => {
|
||||
Ok((None, protocol))
|
||||
},
|
||||
Err(e) => Err(RequestError::InvalidResponse(e)),
|
||||
}
|
||||
} else {
|
||||
@@ -485,10 +488,12 @@ impl State {
|
||||
match request_result {
|
||||
Ok((maybe_chunk, protocol)) => {
|
||||
match protocol {
|
||||
name if name == params.req_v1_protocol_name =>
|
||||
params.metrics.on_chunk_response_v1(),
|
||||
name if name == params.req_v2_protocol_name =>
|
||||
params.metrics.on_chunk_response_v2(),
|
||||
name if name == params.req_v1_protocol_name => {
|
||||
params.metrics.on_chunk_response_v1()
|
||||
},
|
||||
name if name == params.req_v2_protocol_name => {
|
||||
params.metrics.on_chunk_response_v2()
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
|
||||
|
||||
@@ -104,8 +104,8 @@ impl FetchSystematicChunks {
|
||||
let chunks = state
|
||||
.received_chunks
|
||||
.range(
|
||||
ChunkIndex(0)..
|
||||
ChunkIndex(
|
||||
ChunkIndex(0)
|
||||
..ChunkIndex(
|
||||
u32::try_from(self.threshold)
|
||||
.expect("validator count should not exceed u32"),
|
||||
),
|
||||
@@ -180,8 +180,8 @@ impl<Sender: overseer::AvailabilityRecoverySenderTrait> RecoveryStrategy<Sender>
|
||||
for (_, our_c_index) in &local_chunk_indices {
|
||||
// If we are among the systematic validators but hold an invalid chunk, we cannot
|
||||
// perform the systematic recovery. Fall through to the next strategy.
|
||||
if self.validators.iter().any(|(c_index, _)| c_index == our_c_index) &&
|
||||
!state.received_chunks.contains_key(our_c_index)
|
||||
if self.validators.iter().any(|(c_index, _)| c_index == our_c_index)
|
||||
&& !state.received_chunks.contains_key(our_c_index)
|
||||
{
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
@@ -201,8 +201,8 @@ impl<Sender: overseer::AvailabilityRecoverySenderTrait> RecoveryStrategy<Sender>
|
||||
// No need to query the validators that have the chunks we already received or that we know
|
||||
// don't have the data from previous strategies.
|
||||
self.validators.retain(|(c_index, v_index)| {
|
||||
!state.received_chunks.contains_key(c_index) &&
|
||||
state.can_retry_request(
|
||||
!state.received_chunks.contains_key(c_index)
|
||||
&& state.can_retry_request(
|
||||
&(common_params.validator_authority_keys[v_index.0 as usize].clone(), *v_index),
|
||||
SYSTEMATIC_CHUNKS_REQ_RETRY_LIMIT,
|
||||
)
|
||||
|
||||
@@ -2499,8 +2499,8 @@ fn systematic_chunks_are_not_requested_again_in_regular_recovery() {
|
||||
&mut virtual_overseer,
|
||||
1,
|
||||
|i| {
|
||||
if (test_state.chunks.get(i).unwrap().index.0 as usize) <
|
||||
test_state.systematic_threshold()
|
||||
if (test_state.chunks.get(i).unwrap().index.0 as usize)
|
||||
< test_state.systematic_threshold()
|
||||
{
|
||||
panic!("Already requested")
|
||||
} else {
|
||||
|
||||
@@ -90,11 +90,12 @@ impl BitfieldGossipMessage {
|
||||
recipient_version: ProtocolVersion,
|
||||
) -> net_protocol::BitfieldDistributionMessage {
|
||||
match ValidationVersion::try_from(recipient_version).ok() {
|
||||
Some(ValidationVersion::V3) =>
|
||||
Some(ValidationVersion::V3) => {
|
||||
ValidationProtocols::V3(protocol_v3::BitfieldDistributionMessage::Bitfield(
|
||||
self.relay_parent,
|
||||
self.signed_availability.into(),
|
||||
)),
|
||||
))
|
||||
},
|
||||
None => {
|
||||
gum::warn!(
|
||||
target: LOG_TARGET,
|
||||
@@ -187,8 +188,9 @@ impl PerRelayParentData {
|
||||
self.message_sent_to_peer
|
||||
.get(peer)
|
||||
.map(|pubkeys| !pubkeys.contains(signed_by))
|
||||
.unwrap_or(true) &&
|
||||
self.message_received_from_peer
|
||||
.unwrap_or(true)
|
||||
&& self
|
||||
.message_received_from_peer
|
||||
.get(peer)
|
||||
.map(|pubkeys| !pubkeys.contains(signed_by))
|
||||
.unwrap_or(true)
|
||||
@@ -729,8 +731,9 @@ async fn handle_network_msg<Context>(
|
||||
gum::trace!(target: LOG_TARGET, ?new_view, "Our view change");
|
||||
handle_our_view_change(state, new_view);
|
||||
},
|
||||
NetworkBridgeEvent::PeerMessage(remote, message) =>
|
||||
process_incoming_peer_message(ctx, state, metrics, remote, message, rng).await,
|
||||
NetworkBridgeEvent::PeerMessage(remote, message) => {
|
||||
process_incoming_peer_message(ctx, state, metrics, remote, message, rng).await
|
||||
},
|
||||
NetworkBridgeEvent::UpdatedAuthorityIds(peer_id, authority_ids) => {
|
||||
state
|
||||
.topologies
|
||||
@@ -794,8 +797,8 @@ async fn handle_peer_view_change<Context>(
|
||||
let topology = state.topologies.get_current_topology().local_grid_neighbors();
|
||||
let is_gossip_peer = topology.route_to_peer(RequiredRouting::GridXY, &origin);
|
||||
|
||||
let lucky = is_gossip_peer ||
|
||||
util::gen_ratio_rng(
|
||||
let lucky = is_gossip_peer
|
||||
|| util::gen_ratio_rng(
|
||||
util::MIN_GOSSIP_PEERS.saturating_sub(topology.len()),
|
||||
util::MIN_GOSSIP_PEERS,
|
||||
rng,
|
||||
@@ -904,8 +907,9 @@ async fn query_basics<Context>(
|
||||
.await;
|
||||
|
||||
match (validators_rx.await?, session_rx.await?) {
|
||||
(Ok(validators), Ok(session_index)) =>
|
||||
Ok(Some((validators, SigningContext { parent_hash: relay_parent, session_index }))),
|
||||
(Ok(validators), Ok(session_index)) => {
|
||||
Ok(Some((validators, SigningContext { parent_hash: relay_parent, session_index })))
|
||||
},
|
||||
(Err(err), _) | (_, Err(err)) => {
|
||||
gum::warn!(
|
||||
target: LOG_TARGET,
|
||||
|
||||
@@ -1024,8 +1024,8 @@ fn handle_peer_messages<RawMessage: Decode, OutMessage: From<RawMessage>>(
|
||||
|
||||
outgoing_events.push(match message {
|
||||
WireMessage::ViewUpdate(new_view) => {
|
||||
if new_view.len() > MAX_VIEW_HEADS ||
|
||||
new_view.finalized_number < peer_data.view.finalized_number
|
||||
if new_view.len() > MAX_VIEW_HEADS
|
||||
|| new_view.finalized_number < peer_data.view.finalized_number
|
||||
{
|
||||
reports.push(MALFORMED_VIEW_COST);
|
||||
continue;
|
||||
@@ -1040,8 +1040,9 @@ fn handle_peer_messages<RawMessage: Decode, OutMessage: From<RawMessage>>(
|
||||
NetworkBridgeEvent::PeerViewChange(peer, peer_data.view.clone())
|
||||
}
|
||||
},
|
||||
WireMessage::ProtocolMessage(message) =>
|
||||
NetworkBridgeEvent::PeerMessage(peer, message.into()),
|
||||
WireMessage::ProtocolMessage(message) => {
|
||||
NetworkBridgeEvent::PeerMessage(peer, message.into())
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1123,9 +1124,9 @@ async fn dispatch_validation_events_to_all<I>(
|
||||
// NetworkBridgeEvent::OurViewChange(..) must also be here,
|
||||
// but it is sent via an unbounded channel.
|
||||
// See https://github.com/pezkuwichain/pezkuwi-sdk/issues/108
|
||||
NetworkBridgeEvent::PeerConnected(..) |
|
||||
NetworkBridgeEvent::PeerDisconnected(..) |
|
||||
NetworkBridgeEvent::PeerViewChange(..)
|
||||
NetworkBridgeEvent::PeerConnected(..)
|
||||
| NetworkBridgeEvent::PeerDisconnected(..)
|
||||
| NetworkBridgeEvent::PeerViewChange(..)
|
||||
);
|
||||
let message = $message::from(event);
|
||||
if has_high_priority {
|
||||
|
||||
@@ -488,8 +488,8 @@ async fn await_peer_connections(
|
||||
loop {
|
||||
{
|
||||
let shared = shared.0.lock();
|
||||
if shared.validation_peers.len() == num_validation_peers &&
|
||||
shared.collation_peers.len() == num_collation_peers
|
||||
if shared.validation_peers.len() == num_validation_peers
|
||||
&& shared.collation_peers.len() == num_collation_peers
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -1516,13 +1516,16 @@ fn network_protocol_versioning_view_update() {
|
||||
|
||||
for &(peer_id, peer_set, version) in &peers {
|
||||
let wire_msg = match (version.into(), peer_set) {
|
||||
(1, PeerSet::Collation) =>
|
||||
WireMessage::<protocol_v1::CollationProtocol>::ViewUpdate(view.clone()).encode(),
|
||||
(2, PeerSet::Collation) =>
|
||||
WireMessage::<protocol_v2::CollationProtocol>::ViewUpdate(view.clone()).encode(),
|
||||
(3, PeerSet::Validation) =>
|
||||
(1, PeerSet::Collation) => {
|
||||
WireMessage::<protocol_v1::CollationProtocol>::ViewUpdate(view.clone()).encode()
|
||||
},
|
||||
(2, PeerSet::Collation) => {
|
||||
WireMessage::<protocol_v2::CollationProtocol>::ViewUpdate(view.clone()).encode()
|
||||
},
|
||||
(3, PeerSet::Validation) => {
|
||||
WireMessage::<protocol_v3::ValidationProtocol>::ViewUpdate(view.clone())
|
||||
.encode(),
|
||||
.encode()
|
||||
},
|
||||
_ => unreachable!(),
|
||||
};
|
||||
assert_network_actions_contains(
|
||||
|
||||
@@ -288,8 +288,9 @@ where
|
||||
metrics.on_message("chunk_fetching_v1")
|
||||
}
|
||||
},
|
||||
Requests::AvailableDataFetchingV1(_) =>
|
||||
metrics.on_message("available_data_fetching_v1"),
|
||||
Requests::AvailableDataFetchingV1(_) => {
|
||||
metrics.on_message("available_data_fetching_v1")
|
||||
},
|
||||
Requests::CollationFetchingV1(_) => metrics.on_message("collation_fetching_v1"),
|
||||
Requests::CollationFetchingV2(_) => metrics.on_message("collation_fetching_v2"),
|
||||
Requests::PoVFetchingV1(_) => metrics.on_message("pov_fetching_v1"),
|
||||
|
||||
@@ -1052,8 +1052,8 @@ async fn handle_incoming_peer_message<Context>(
|
||||
))
|
||||
.await;
|
||||
},
|
||||
CollationProtocols::V1(V1::AdvertiseCollation(_)) |
|
||||
CollationProtocols::V2(V2::AdvertiseCollation { .. }) => {
|
||||
CollationProtocols::V1(V1::AdvertiseCollation(_))
|
||||
| CollationProtocols::V2(V2::AdvertiseCollation { .. }) => {
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
?origin,
|
||||
@@ -1174,8 +1174,9 @@ async fn handle_incoming_request<Context>(
|
||||
};
|
||||
|
||||
let collation_with_core = match &req {
|
||||
VersionedCollationRequest::V2(req) =>
|
||||
per_relay_parent.collations.get_mut(&req.payload.candidate_hash),
|
||||
VersionedCollationRequest::V2(req) => {
|
||||
per_relay_parent.collations.get_mut(&req.payload.candidate_hash)
|
||||
},
|
||||
};
|
||||
let (receipt, pov, parent_head_data) =
|
||||
if let Some(collation_with_core) = collation_with_core {
|
||||
@@ -1634,7 +1635,7 @@ fn process_out_of_view_collation(
|
||||
let candidate_hash = collation.receipt.hash();
|
||||
|
||||
match collation.status {
|
||||
CollationStatus::Created =>
|
||||
CollationStatus::Created => {
|
||||
if is_same_session {
|
||||
gum::warn!(
|
||||
target: LOG_TARGET,
|
||||
@@ -1649,7 +1650,8 @@ fn process_out_of_view_collation(
|
||||
pov_hash = ?collation.pov.hash(),
|
||||
"Collation wasn't advertised because it was built on a relay chain block that is now part of an old session.",
|
||||
)
|
||||
},
|
||||
}
|
||||
},
|
||||
CollationStatus::Advertised => gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
?candidate_hash,
|
||||
|
||||
@@ -548,8 +548,9 @@ fn decode_collation_response(bytes: &[u8]) -> (CandidateReceipt, PoV) {
|
||||
CollationFetchingResponse::Collation(_, _) => {
|
||||
panic!("Expected to always receive CollationWithParentHeadData")
|
||||
},
|
||||
CollationFetchingResponse::CollationWithParentHeadData { receipt, pov, .. } =>
|
||||
(receipt, pov),
|
||||
CollationFetchingResponse::CollationWithParentHeadData { receipt, pov, .. } => {
|
||||
(receipt, pov)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -151,14 +151,16 @@ impl<Context> CollatorProtocolSubsystem {
|
||||
.boxed()
|
||||
},
|
||||
#[cfg(feature = "experimental-collator-protocol")]
|
||||
ProtocolSide::ValidatorExperimental { keystore, metrics } =>
|
||||
ProtocolSide::ValidatorExperimental { keystore, metrics } => {
|
||||
validator_side_experimental::run(ctx, keystore, metrics)
|
||||
.map_err(|e| SubsystemError::with_origin("collator-protocol", e))
|
||||
.boxed(),
|
||||
ProtocolSide::Collator { peer_id, collator_pair, request_receiver_v2, metrics } =>
|
||||
.boxed()
|
||||
},
|
||||
ProtocolSide::Collator { peer_id, collator_pair, request_receiver_v2, metrics } => {
|
||||
collator_side::run(ctx, peer_id, collator_pair, request_receiver_v2, metrics)
|
||||
.map_err(|e| SubsystemError::with_origin("collator-protocol", e))
|
||||
.boxed(),
|
||||
.boxed()
|
||||
},
|
||||
ProtocolSide::None => return DummySubsystem.start(ctx),
|
||||
};
|
||||
|
||||
|
||||
@@ -98,13 +98,13 @@ impl SecondingError {
|
||||
use SecondingError::*;
|
||||
matches!(
|
||||
self,
|
||||
PersistedValidationDataMismatch |
|
||||
CandidateHashMismatch |
|
||||
RelayParentMismatch |
|
||||
ParentHeadDataMismatch |
|
||||
InvalidCoreIndex(_, _) |
|
||||
InvalidSessionIndex(_, _) |
|
||||
InvalidReceiptVersion(_)
|
||||
PersistedValidationDataMismatch
|
||||
| CandidateHashMismatch
|
||||
| RelayParentMismatch
|
||||
| ParentHeadDataMismatch
|
||||
| InvalidCoreIndex(_, _)
|
||||
| InvalidSessionIndex(_, _)
|
||||
| InvalidReceiptVersion(_)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,8 +335,9 @@ impl PeerData {
|
||||
fn is_inactive(&self, policy: &crate::CollatorEvictionPolicy) -> bool {
|
||||
match self.state {
|
||||
PeerState::Connected(connected_at) => connected_at.elapsed() >= policy.undeclared,
|
||||
PeerState::Collating(ref state) =>
|
||||
state.last_active.elapsed() >= policy.inactive_collator,
|
||||
PeerState::Collating(ref state) => {
|
||||
state.last_active.elapsed() >= policy.inactive_collator
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -540,8 +541,8 @@ impl State {
|
||||
acc + blocked_collations
|
||||
.iter()
|
||||
.filter(|pc| {
|
||||
pc.candidate_receipt.descriptor.para_id() == *para_id &&
|
||||
pc.candidate_receipt.descriptor.relay_parent() == *relay_parent
|
||||
pc.candidate_receipt.descriptor.para_id() == *para_id
|
||||
&& pc.candidate_receipt.descriptor.relay_parent() == *relay_parent
|
||||
})
|
||||
.count()
|
||||
});
|
||||
@@ -747,14 +748,16 @@ async fn notify_collation_seconded(
|
||||
) {
|
||||
let statement = statement.into();
|
||||
let wire_message = match version {
|
||||
CollationVersion::V1 =>
|
||||
CollationVersion::V1 => {
|
||||
CollationProtocols::V1(protocol_v1::CollationProtocol::CollatorProtocol(
|
||||
protocol_v1::CollatorProtocolMessage::CollationSeconded(relay_parent, statement),
|
||||
)),
|
||||
CollationVersion::V2 =>
|
||||
))
|
||||
},
|
||||
CollationVersion::V2 => {
|
||||
CollationProtocols::V2(protocol_v2::CollationProtocol::CollatorProtocol(
|
||||
protocol_v2::CollatorProtocolMessage::CollationSeconded(relay_parent, statement),
|
||||
)),
|
||||
))
|
||||
},
|
||||
};
|
||||
sender
|
||||
.send_message(NetworkBridgeTxMessage::SendCollationMessage(vec![peer_id], wire_message))
|
||||
@@ -879,8 +882,8 @@ async fn process_incoming_peer_message<Context>(
|
||||
use protocol_v2::CollatorProtocolMessage as V2;
|
||||
|
||||
match msg {
|
||||
CollationProtocols::V1(V1::Declare(collator_id, para_id, signature)) |
|
||||
CollationProtocols::V2(V2::Declare(collator_id, para_id, signature)) => {
|
||||
CollationProtocols::V1(V1::Declare(collator_id, para_id, signature))
|
||||
| CollationProtocols::V2(V2::Declare(collator_id, para_id, signature)) => {
|
||||
if collator_peer_id(&state.peer_data, &collator_id).is_some() {
|
||||
modify_reputation(
|
||||
&mut state.reputation,
|
||||
@@ -1022,8 +1025,8 @@ async fn process_incoming_peer_message<Context>(
|
||||
}
|
||||
}
|
||||
},
|
||||
CollationProtocols::V1(V1::CollationSeconded(..)) |
|
||||
CollationProtocols::V2(V2::CollationSeconded(..)) => {
|
||||
CollationProtocols::V1(V1::CollationSeconded(..))
|
||||
| CollationProtocols::V2(V2::CollationSeconded(..)) => {
|
||||
gum::warn!(
|
||||
target: LOG_TARGET,
|
||||
peer_id = ?origin,
|
||||
@@ -1053,9 +1056,9 @@ fn hold_off_asset_hub_collation_if_needed(
|
||||
let peer_is_invulnerable = state.ah_invulnerables.contains(&peer_id);
|
||||
let invulnerables_set_is_empty = state.ah_invulnerables.is_empty();
|
||||
|
||||
if maybe_para_id != Some(ASSET_HUB_PARA_ID) ||
|
||||
peer_is_invulnerable ||
|
||||
invulnerables_set_is_empty
|
||||
if maybe_para_id != Some(ASSET_HUB_PARA_ID)
|
||||
|| peer_is_invulnerable
|
||||
|| invulnerables_set_is_empty
|
||||
{
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
@@ -1269,8 +1272,8 @@ fn ensure_seconding_limit_is_respected(
|
||||
for path in paths {
|
||||
let mut cq_state = ClaimQueueState::new();
|
||||
for ancestor in &path {
|
||||
let seconded_and_pending = state.seconded_and_pending_for_para(&ancestor, ¶_id) +
|
||||
state.in_waiting_queue_for_para(relay_parent, ¶_id);
|
||||
let seconded_and_pending = state.seconded_and_pending_for_para(&ancestor, ¶_id)
|
||||
+ state.in_waiting_queue_for_para(relay_parent, ¶_id);
|
||||
cq_state.add_leaf(
|
||||
&ancestor,
|
||||
&state
|
||||
@@ -1847,9 +1850,11 @@ async fn process_msg<Context>(
|
||||
let candidate_hash = fetched_collation.candidate_hash;
|
||||
let id = match state.fetched_candidates.entry(fetched_collation) {
|
||||
Entry::Occupied(entry)
|
||||
if entry.get().pending_collation.commitments_hash ==
|
||||
Some(candidate_receipt.commitments_hash) =>
|
||||
entry.remove().collator_id,
|
||||
if entry.get().pending_collation.commitments_hash
|
||||
== Some(candidate_receipt.commitments_hash) =>
|
||||
{
|
||||
entry.remove().collator_id
|
||||
},
|
||||
Entry::Occupied(_) => {
|
||||
gum::error!(
|
||||
target: LOG_TARGET,
|
||||
@@ -2400,10 +2405,10 @@ async fn handle_collation_fetch_response(
|
||||
Err(None)
|
||||
},
|
||||
Ok(
|
||||
request_v1::CollationFetchingResponse::Collation(receipt, _) |
|
||||
request_v2::CollationFetchingResponse::Collation(receipt, _) |
|
||||
request_v1::CollationFetchingResponse::CollationWithParentHeadData { receipt, .. } |
|
||||
request_v2::CollationFetchingResponse::CollationWithParentHeadData { receipt, .. },
|
||||
request_v1::CollationFetchingResponse::Collation(receipt, _)
|
||||
| request_v2::CollationFetchingResponse::Collation(receipt, _)
|
||||
| request_v1::CollationFetchingResponse::CollationWithParentHeadData { receipt, .. }
|
||||
| request_v2::CollationFetchingResponse::CollationWithParentHeadData { receipt, .. },
|
||||
) if receipt.descriptor().para_id() != pending_collation.para_id => {
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
@@ -2550,8 +2555,8 @@ fn get_next_collation_to_fetch(
|
||||
// to replace it.
|
||||
if let Some((collator_id, maybe_candidate_hash)) = rp_state.collations.fetching_from.as_ref() {
|
||||
// If a candidate hash was saved previously, `finished_one` must include this too.
|
||||
if collator_id != &finished_one.0 &&
|
||||
maybe_candidate_hash.map_or(true, |hash| Some(&hash) != finished_one.1.as_ref())
|
||||
if collator_id != &finished_one.0
|
||||
&& maybe_candidate_hash.map_or(true, |hash| Some(&hash) != finished_one.1.as_ref())
|
||||
{
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
|
||||
@@ -416,18 +416,20 @@ async fn connect_and_declare_collator(
|
||||
.await;
|
||||
|
||||
let wire_message = match version {
|
||||
CollationVersion::V1 =>
|
||||
CollationVersion::V1 => {
|
||||
CollationProtocols::V1(protocol_v1::CollatorProtocolMessage::Declare(
|
||||
collator.public(),
|
||||
para_id,
|
||||
collator.sign(&protocol_v1::declare_signature_payload(&peer)),
|
||||
)),
|
||||
CollationVersion::V2 =>
|
||||
))
|
||||
},
|
||||
CollationVersion::V2 => {
|
||||
CollationProtocols::V2(protocol_v2::CollatorProtocolMessage::Declare(
|
||||
collator.public(),
|
||||
para_id,
|
||||
collator.sign(&protocol_v1::declare_signature_payload(&peer)),
|
||||
)),
|
||||
))
|
||||
},
|
||||
};
|
||||
|
||||
overseer_send(
|
||||
@@ -448,12 +450,13 @@ async fn advertise_collation(
|
||||
candidate: Option<(CandidateHash, Hash)>, // Candidate hash + parent head data hash.
|
||||
) {
|
||||
let wire_message = match candidate {
|
||||
Some((candidate_hash, parent_head_data_hash)) =>
|
||||
Some((candidate_hash, parent_head_data_hash)) => {
|
||||
CollationProtocols::V2(protocol_v2::CollatorProtocolMessage::AdvertiseCollation {
|
||||
relay_parent,
|
||||
candidate_hash,
|
||||
parent_head_data_hash,
|
||||
}),
|
||||
})
|
||||
},
|
||||
None => CollationProtocols::V1(protocol_v1::CollatorProtocolMessage::AdvertiseCollation(
|
||||
relay_parent,
|
||||
)),
|
||||
|
||||
+30
-20
@@ -104,12 +104,13 @@ impl ConnectedPeers {
|
||||
outcome = outcome.combine(res);
|
||||
}
|
||||
},
|
||||
PeerState::Connected =>
|
||||
PeerState::Connected => {
|
||||
for (para_id, per_para) in self.per_para.iter_mut() {
|
||||
let past_reputation = reputation_query_fn(peer_id, *para_id).await;
|
||||
let res = per_para.try_accept(peer_id, past_reputation);
|
||||
outcome = outcome.combine(res);
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
match outcome {
|
||||
@@ -567,12 +568,15 @@ mod tests {
|
||||
let rep_query_fn = |peer_id, para_id| async move {
|
||||
match (peer_id, para_id) {
|
||||
(peer_id, para_id) if peer_id == first_peer => Score::new(10).unwrap(),
|
||||
(peer_id, para_id) if peer_id == second_peer && para_id == para_1 =>
|
||||
Score::new(20).unwrap(),
|
||||
(peer_id, para_id) if peer_id == third_peer && para_id == para_2 =>
|
||||
Score::new(20).unwrap(),
|
||||
(peer_id, para_id) if peer_id == new_peer && para_id == para_1 =>
|
||||
Score::new(5).unwrap(),
|
||||
(peer_id, para_id) if peer_id == second_peer && para_id == para_1 => {
|
||||
Score::new(20).unwrap()
|
||||
},
|
||||
(peer_id, para_id) if peer_id == third_peer && para_id == para_2 => {
|
||||
Score::new(20).unwrap()
|
||||
},
|
||||
(peer_id, para_id) if peer_id == new_peer && para_id == para_1 => {
|
||||
Score::new(5).unwrap()
|
||||
},
|
||||
|
||||
(_, _) => Score::default(),
|
||||
}
|
||||
@@ -714,12 +718,15 @@ mod tests {
|
||||
let rep_query_fn = |peer_id, para_id| async move {
|
||||
match (peer_id, para_id) {
|
||||
(peer_id, para_id) if peer_id == first_peer => Score::new(10).unwrap(),
|
||||
(peer_id, para_id) if peer_id == second_peer && para_id == para_1 =>
|
||||
Score::new(20).unwrap(),
|
||||
(peer_id, para_id) if peer_id == third_peer && para_id == para_2 =>
|
||||
Score::new(20).unwrap(),
|
||||
(peer_id, para_id) if peer_id == fourth_peer && para_id == para_2 =>
|
||||
Score::new(15).unwrap(),
|
||||
(peer_id, para_id) if peer_id == second_peer && para_id == para_1 => {
|
||||
Score::new(20).unwrap()
|
||||
},
|
||||
(peer_id, para_id) if peer_id == third_peer && para_id == para_2 => {
|
||||
Score::new(20).unwrap()
|
||||
},
|
||||
(peer_id, para_id) if peer_id == fourth_peer && para_id == para_2 => {
|
||||
Score::new(15).unwrap()
|
||||
},
|
||||
(peer_id, para_id) if peer_id == new_peer => Score::new(30).unwrap(),
|
||||
|
||||
(_, _) => Score::default(),
|
||||
@@ -863,12 +870,15 @@ mod tests {
|
||||
let rep_query_fn = |peer_id, para_id| async move {
|
||||
match (peer_id, para_id) {
|
||||
(peer_id, para_id) if peer_id == first_peer => Score::new(10).unwrap(),
|
||||
(peer_id, para_id) if peer_id == second_peer && para_id == para_1 =>
|
||||
Score::new(5).unwrap(),
|
||||
(peer_id, para_id) if peer_id == third_peer && para_id == para_2 =>
|
||||
Score::new(5).unwrap(),
|
||||
(peer_id, para_id) if peer_id == new_peer && para_id == para_1 =>
|
||||
Score::new(8).unwrap(),
|
||||
(peer_id, para_id) if peer_id == second_peer && para_id == para_1 => {
|
||||
Score::new(5).unwrap()
|
||||
},
|
||||
(peer_id, para_id) if peer_id == third_peer && para_id == para_2 => {
|
||||
Score::new(5).unwrap()
|
||||
},
|
||||
(peer_id, para_id) if peer_id == new_peer && para_id == para_1 => {
|
||||
Score::new(8).unwrap()
|
||||
},
|
||||
|
||||
(_, _) => Score::default(),
|
||||
}
|
||||
|
||||
@@ -210,8 +210,9 @@ where
|
||||
Err(f) => Err(f),
|
||||
}
|
||||
},
|
||||
FromOrchestra::Communication { msg } =>
|
||||
self.handle_subsystem_message(&mut ctx, msg).await,
|
||||
FromOrchestra::Communication { msg } => {
|
||||
self.handle_subsystem_message(&mut ctx, msg).await
|
||||
},
|
||||
};
|
||||
log_error(result, "on FromOrchestra")?;
|
||||
},
|
||||
@@ -254,8 +255,9 @@ where
|
||||
msg: DisputeDistributionMessage,
|
||||
) -> Result<()> {
|
||||
match msg {
|
||||
DisputeDistributionMessage::SendDispute(dispute_msg) =>
|
||||
self.disputes_sender.start_sender(ctx, &mut self.runtime, dispute_msg).await?,
|
||||
DisputeDistributionMessage::SendDispute(dispute_msg) => {
|
||||
self.disputes_sender.start_sender(ctx, &mut self.runtime, dispute_msg).await?
|
||||
},
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -177,8 +177,8 @@ impl Batch {
|
||||
/// This function is supposed to be called at instants given at construction and as returned as
|
||||
/// part of `TickResult`.
|
||||
pub(super) fn tick(mut self, now: Instant) -> TickResult {
|
||||
if self.votes_batched_since_last_tick >= MIN_KEEP_BATCH_ALIVE_VOTES &&
|
||||
now < self.best_before
|
||||
if self.votes_batched_since_last_tick >= MIN_KEEP_BATCH_ALIVE_VOTES
|
||||
&& now < self.best_before
|
||||
{
|
||||
// Still good:
|
||||
let next_tick = self.calculate_next_tick(now);
|
||||
|
||||
@@ -315,8 +315,9 @@ async fn wait_response_task<M: 'static + Send + Sync>(
|
||||
let result = pending_response.await;
|
||||
let msg = match result {
|
||||
Err(err) => TaskFinish { candidate_hash, receiver, result: TaskResult::Failed(err) },
|
||||
Ok(DisputeResponse::Confirmed) =>
|
||||
TaskFinish { candidate_hash, receiver, result: TaskResult::Succeeded },
|
||||
Ok(DisputeResponse::Confirmed) => {
|
||||
TaskFinish { candidate_hash, receiver, result: TaskResult::Succeeded }
|
||||
},
|
||||
};
|
||||
if let Err(err) = tx.send_message(msg).await {
|
||||
gum::debug!(
|
||||
|
||||
@@ -210,7 +210,7 @@ where
|
||||
gum::debug!(target: LOG_TARGET, error = ?e);
|
||||
}
|
||||
},
|
||||
FromOrchestra::Signal(OverseerSignal::BlockFinalized(_hash, _number)) =>
|
||||
FromOrchestra::Signal(OverseerSignal::BlockFinalized(_hash, _number)) => {
|
||||
if let Some(session_index) = self.last_session_index {
|
||||
if let Err(e) = self
|
||||
.build_topology_for_last_finalized_if_needed(
|
||||
@@ -225,7 +225,8 @@ where
|
||||
e
|
||||
);
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
FromOrchestra::Signal(OverseerSignal::Conclude) => return self,
|
||||
}
|
||||
}
|
||||
@@ -394,8 +395,8 @@ where
|
||||
.await
|
||||
.await??;
|
||||
|
||||
if finalized_session_index < self.min_known_session &&
|
||||
Some(finalized_session_index) != self.finalized_needed_session
|
||||
if finalized_session_index < self.min_known_session
|
||||
&& Some(finalized_session_index) != self.finalized_needed_session
|
||||
{
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
|
||||
@@ -586,12 +586,12 @@ impl RequiredRouting {
|
||||
match (self, other) {
|
||||
(RequiredRouting::All, _) | (_, RequiredRouting::All) => RequiredRouting::All,
|
||||
(RequiredRouting::GridXY, _) | (_, RequiredRouting::GridXY) => RequiredRouting::GridXY,
|
||||
(RequiredRouting::GridX, RequiredRouting::GridY) |
|
||||
(RequiredRouting::GridY, RequiredRouting::GridX) => RequiredRouting::GridXY,
|
||||
(RequiredRouting::GridX, RequiredRouting::GridY)
|
||||
| (RequiredRouting::GridY, RequiredRouting::GridX) => RequiredRouting::GridXY,
|
||||
(RequiredRouting::GridX, RequiredRouting::GridX) => RequiredRouting::GridX,
|
||||
(RequiredRouting::GridY, RequiredRouting::GridY) => RequiredRouting::GridY,
|
||||
(RequiredRouting::None, RequiredRouting::PendingTopology) |
|
||||
(RequiredRouting::PendingTopology, RequiredRouting::None) => RequiredRouting::PendingTopology,
|
||||
(RequiredRouting::None, RequiredRouting::PendingTopology)
|
||||
| (RequiredRouting::PendingTopology, RequiredRouting::None) => RequiredRouting::PendingTopology,
|
||||
(RequiredRouting::None, _) | (RequiredRouting::PendingTopology, _) => other,
|
||||
(_, RequiredRouting::None) | (_, RequiredRouting::PendingTopology) => self,
|
||||
}
|
||||
|
||||
@@ -346,8 +346,9 @@ macro_rules! impl_versioned_validation_try_from {
|
||||
fn try_from(x: &'a $from) -> Result<$out, Self::Error> {
|
||||
#[allow(unreachable_patterns)] // when there is only one variant
|
||||
match x {
|
||||
ValidationProtocols::V3($v3_pat) =>
|
||||
Ok(ValidationProtocols::V3($v3_out.clone())),
|
||||
ValidationProtocols::V3($v3_pat) => {
|
||||
Ok(ValidationProtocols::V3($v3_out.clone()))
|
||||
},
|
||||
_ => Err(crate::WrongVariant),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,20 +168,22 @@ impl PeerSet {
|
||||
// Unfortunately, labels must be static strings, so we must manually cover them
|
||||
// for all protocol versions here.
|
||||
match self {
|
||||
PeerSet::Validation =>
|
||||
PeerSet::Validation => {
|
||||
if version == ValidationVersion::V3.into() {
|
||||
Some("validation/3")
|
||||
} else {
|
||||
None
|
||||
},
|
||||
PeerSet::Collation =>
|
||||
}
|
||||
},
|
||||
PeerSet::Collation => {
|
||||
if version == CollationVersion::V1.into() {
|
||||
Some("collation/1")
|
||||
} else if version == CollationVersion::V2.into() {
|
||||
Some("collation/2")
|
||||
} else {
|
||||
None
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -320,7 +322,7 @@ impl PeerSetProtocolNames {
|
||||
let mut names = HashMap::new();
|
||||
for protocol in PeerSet::iter() {
|
||||
match protocol {
|
||||
PeerSet::Validation =>
|
||||
PeerSet::Validation => {
|
||||
for version in ValidationVersion::iter() {
|
||||
Self::register_main_protocol(
|
||||
&mut protocols,
|
||||
@@ -330,7 +332,8 @@ impl PeerSetProtocolNames {
|
||||
&genesis_hash,
|
||||
fork_id,
|
||||
);
|
||||
},
|
||||
}
|
||||
},
|
||||
PeerSet::Collation => {
|
||||
for version in CollationVersion::iter() {
|
||||
Self::register_main_protocol(
|
||||
@@ -566,7 +569,7 @@ mod tests {
|
||||
|
||||
for protocol in PeerSet::iter() {
|
||||
match protocol {
|
||||
PeerSet::Validation =>
|
||||
PeerSet::Validation => {
|
||||
for version in ValidationVersion::iter() {
|
||||
assert_eq!(
|
||||
protocol_names.get_name(protocol, version.into()),
|
||||
@@ -577,8 +580,9 @@ mod tests {
|
||||
version.into(),
|
||||
),
|
||||
);
|
||||
},
|
||||
PeerSet::Collation =>
|
||||
}
|
||||
},
|
||||
PeerSet::Collation => {
|
||||
for version in CollationVersion::iter() {
|
||||
assert_eq!(
|
||||
protocol_names.get_name(protocol, version.into()),
|
||||
@@ -589,7 +593,8 @@ mod tests {
|
||||
version.into(),
|
||||
),
|
||||
);
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -598,18 +603,20 @@ mod tests {
|
||||
fn all_protocol_versions_have_labels() {
|
||||
for protocol in PeerSet::iter() {
|
||||
match protocol {
|
||||
PeerSet::Validation =>
|
||||
PeerSet::Validation => {
|
||||
for version in ValidationVersion::iter() {
|
||||
protocol
|
||||
.get_protocol_label(version.into())
|
||||
.expect("All validation protocol versions must have a label.");
|
||||
},
|
||||
PeerSet::Collation =>
|
||||
}
|
||||
},
|
||||
PeerSet::Collation => {
|
||||
for version in CollationVersion::iter() {
|
||||
protocol
|
||||
.get_protocol_label(version.into())
|
||||
.expect("All collation protocol versions must have a label.");
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,10 +74,10 @@ impl UnifiedReputationChange {
|
||||
/// Whether the reputation change is for good behavior.
|
||||
pub const fn is_benefit(&self) -> bool {
|
||||
match self {
|
||||
Self::BenefitMajorFirst(_) |
|
||||
Self::BenefitMajor(_) |
|
||||
Self::BenefitMinorFirst(_) |
|
||||
Self::BenefitMinor(_) => true,
|
||||
Self::BenefitMajorFirst(_)
|
||||
| Self::BenefitMajor(_)
|
||||
| Self::BenefitMinorFirst(_)
|
||||
| Self::BenefitMinor(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,8 +281,8 @@ impl Protocol {
|
||||
// wasting precious time.
|
||||
let available_bandwidth = 7 * MIN_BANDWIDTH_BYTES / 10;
|
||||
let size = u64::saturating_sub(
|
||||
ATTESTED_CANDIDATE_TIMEOUT.as_millis() as u64 * available_bandwidth /
|
||||
(1000 * MAX_CODE_SIZE as u64),
|
||||
ATTESTED_CANDIDATE_TIMEOUT.as_millis() as u64 * available_bandwidth
|
||||
/ (1000 * MAX_CODE_SIZE as u64),
|
||||
MAX_PARALLEL_ATTESTED_CANDIDATE_REQUESTS as u64,
|
||||
);
|
||||
debug_assert!(
|
||||
|
||||
@@ -91,9 +91,9 @@ impl RequestError {
|
||||
/// Whether the error represents some kind of timeout condition.
|
||||
pub fn is_timed_out(&self) -> bool {
|
||||
match self {
|
||||
Self::Canceled(_) |
|
||||
Self::NetworkError(network::RequestFailure::Obsolete) |
|
||||
Self::NetworkError(network::RequestFailure::Network(
|
||||
Self::Canceled(_)
|
||||
| Self::NetworkError(network::RequestFailure::Obsolete)
|
||||
| Self::NetworkError(network::RequestFailure::Network(
|
||||
network::OutboundFailure::Timeout,
|
||||
)) => true,
|
||||
_ => false,
|
||||
|
||||
@@ -185,9 +185,9 @@ impl Candidates {
|
||||
let mut reckoning = PostConfirmationReckoning::default();
|
||||
|
||||
for (leaf_hash, x) in u.unconfirmed_importable_under {
|
||||
if x.relay_parent == relay_parent &&
|
||||
x.parent_hash == parent_hash &&
|
||||
x.para_id == para_id
|
||||
if x.relay_parent == relay_parent
|
||||
&& x.parent_hash == parent_hash
|
||||
&& x.para_id == para_id
|
||||
{
|
||||
new_confirmed.importable_under.insert(leaf_hash);
|
||||
}
|
||||
@@ -296,8 +296,9 @@ impl Candidates {
|
||||
) {
|
||||
for (c_hash, candidate) in i {
|
||||
match candidate {
|
||||
CandidateState::Unconfirmed(u) =>
|
||||
u.extend_hypotheticals(*c_hash, v, maybe_required_parent),
|
||||
CandidateState::Unconfirmed(u) => {
|
||||
u.extend_hypotheticals(*c_hash, v, maybe_required_parent)
|
||||
},
|
||||
CandidateState::Confirmed(c) => v.push(c.to_hypothetical(*c_hash)),
|
||||
}
|
||||
}
|
||||
@@ -335,7 +336,7 @@ impl Candidates {
|
||||
}
|
||||
};
|
||||
self.candidates.retain(|c_hash, state| match state {
|
||||
CandidateState::Confirmed(ref mut c) =>
|
||||
CandidateState::Confirmed(ref mut c) => {
|
||||
if !relay_parent_live(&c.relay_parent()) {
|
||||
remove_parent_claims(*c_hash, c.parent_head_data_hash(), c.para_id());
|
||||
false
|
||||
@@ -344,7 +345,8 @@ impl Candidates {
|
||||
c.importable_under.remove(leaf_hash);
|
||||
}
|
||||
true
|
||||
},
|
||||
}
|
||||
},
|
||||
CandidateState::Unconfirmed(ref mut c) => {
|
||||
c.on_deactivate_leaves(
|
||||
leaves,
|
||||
@@ -393,9 +395,9 @@ impl CandidateClaims {
|
||||
parent_hash: Hash,
|
||||
para_id: ParaId,
|
||||
) -> bool {
|
||||
self.relay_parent == relay_parent &&
|
||||
self.group_index == group_index &&
|
||||
self.parent_hash_and_id.map_or(true, |p| p == (parent_hash, para_id))
|
||||
self.relay_parent == relay_parent
|
||||
&& self.group_index == group_index
|
||||
&& self.parent_hash_and_id.map_or(true, |p| p == (parent_hash, para_id))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -320,16 +320,16 @@ impl ClusterTracker {
|
||||
) -> bool {
|
||||
// we sent, they sent, or they signed and we received from someone else.
|
||||
|
||||
self.we_sent_seconded(validator, candidate_hash) ||
|
||||
self.they_sent_seconded(validator, candidate_hash) ||
|
||||
self.validator_seconded(validator, candidate_hash)
|
||||
self.we_sent_seconded(validator, candidate_hash)
|
||||
|| self.they_sent_seconded(validator, candidate_hash)
|
||||
|| self.validator_seconded(validator, candidate_hash)
|
||||
}
|
||||
|
||||
/// Whether a validator can request a candidate from us.
|
||||
pub fn can_request(&self, target: ValidatorIndex, candidate_hash: CandidateHash) -> bool {
|
||||
self.validators.contains(&target) &&
|
||||
self.we_sent_seconded(target, candidate_hash) &&
|
||||
!self.they_sent_seconded(target, candidate_hash)
|
||||
self.validators.contains(&target)
|
||||
&& self.we_sent_seconded(target, candidate_hash)
|
||||
&& !self.they_sent_seconded(target, candidate_hash)
|
||||
}
|
||||
|
||||
/// Returns a Vec of pending statements to be sent to a particular validator
|
||||
|
||||
@@ -283,11 +283,13 @@ impl GridTracker {
|
||||
// * They are in the sending set for the group AND we have sent them a manifest AND
|
||||
// the received manifest is partial.
|
||||
ManifestKind::Full => receiving_from,
|
||||
ManifestKind::Acknowledgement =>
|
||||
sending_to &&
|
||||
self.confirmed_backed
|
||||
ManifestKind::Acknowledgement => {
|
||||
sending_to
|
||||
&& self
|
||||
.confirmed_backed
|
||||
.get(&candidate_hash)
|
||||
.map_or(false, |c| c.has_sent_manifest_to(sender)),
|
||||
.map_or(false, |c| c.has_sent_manifest_to(sender))
|
||||
},
|
||||
};
|
||||
|
||||
if !manifest_allowed {
|
||||
@@ -1083,10 +1085,10 @@ impl KnownBackedCandidate {
|
||||
.filter(|k| k.local_knowledge.is_some())
|
||||
.and_then(|k| k.remote_knowledge.as_ref())
|
||||
.map(|remote| StatementFilter {
|
||||
seconded_in_group: full_local.seconded_in_group.clone() &
|
||||
!remote.seconded_in_group.clone(),
|
||||
validated_in_group: full_local.validated_in_group.clone() &
|
||||
!remote.validated_in_group.clone(),
|
||||
seconded_in_group: full_local.seconded_in_group.clone()
|
||||
& !remote.seconded_in_group.clone(),
|
||||
validated_in_group: full_local.validated_in_group.clone()
|
||||
& !remote.validated_in_group.clone(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -494,7 +494,7 @@ pub(crate) async fn handle_network_update<Context>(
|
||||
NetworkBridgeEvent::PeerMessage(peer_id, message) => match message {
|
||||
net_protocol::StatementDistributionMessage::V3(
|
||||
protocol_v3::StatementDistributionMessage::Statement(relay_parent, statement),
|
||||
) =>
|
||||
) => {
|
||||
handle_incoming_statement(
|
||||
ctx,
|
||||
state,
|
||||
@@ -504,18 +504,21 @@ pub(crate) async fn handle_network_update<Context>(
|
||||
reputation,
|
||||
metrics,
|
||||
)
|
||||
.await,
|
||||
.await
|
||||
},
|
||||
net_protocol::StatementDistributionMessage::V3(
|
||||
protocol_v3::StatementDistributionMessage::BackedCandidateManifest(inner),
|
||||
) => handle_incoming_manifest(ctx, state, peer_id, inner, reputation, metrics).await,
|
||||
net_protocol::StatementDistributionMessage::V3(
|
||||
protocol_v3::StatementDistributionMessage::BackedCandidateKnown(inner),
|
||||
) =>
|
||||
) => {
|
||||
handle_incoming_acknowledgement(ctx, state, peer_id, inner, reputation, metrics)
|
||||
.await,
|
||||
.await
|
||||
},
|
||||
},
|
||||
NetworkBridgeEvent::PeerViewChange(peer_id, view) => {
|
||||
handle_peer_view_update(ctx, state, peer_id, view, metrics).await
|
||||
},
|
||||
NetworkBridgeEvent::PeerViewChange(peer_id, view) =>
|
||||
handle_peer_view_update(ctx, state, peer_id, view, metrics).await,
|
||||
NetworkBridgeEvent::OurViewChange(_view) => {
|
||||
// handled by `handle_activated_leaf`
|
||||
},
|
||||
@@ -1161,10 +1164,12 @@ pub(crate) async fn share_local_statement<Context>(
|
||||
// Two possibilities: either the statement is `Seconded` or we already
|
||||
// have the candidate. Sanity: check the para-id is valid.
|
||||
let expected = match statement.payload() {
|
||||
FullStatementWithPVD::Seconded(ref c, _) =>
|
||||
Some((c.descriptor.para_id(), c.descriptor.relay_parent())),
|
||||
FullStatementWithPVD::Valid(hash) =>
|
||||
state.candidates.get_confirmed(&hash).map(|c| (c.para_id(), c.relay_parent())),
|
||||
FullStatementWithPVD::Seconded(ref c, _) => {
|
||||
Some((c.descriptor.para_id(), c.descriptor.relay_parent()))
|
||||
},
|
||||
FullStatementWithPVD::Valid(hash) => {
|
||||
state.candidates.get_confirmed(&hash).map(|c| (c.para_id(), c.relay_parent()))
|
||||
},
|
||||
};
|
||||
|
||||
let is_seconded = match statement.payload() {
|
||||
@@ -1183,8 +1188,8 @@ pub(crate) async fn share_local_statement<Context>(
|
||||
|
||||
let seconding_limit = local_assignments.len();
|
||||
|
||||
if is_seconded &&
|
||||
per_relay_parent.statement_store.seconded_count(&local_index) >= seconding_limit
|
||||
if is_seconded
|
||||
&& per_relay_parent.statement_store.seconded_count(&local_index) >= seconding_limit
|
||||
{
|
||||
gum::warn!(
|
||||
target: LOG_TARGET,
|
||||
@@ -1789,8 +1794,9 @@ fn handle_cluster_statement(
|
||||
Ok(ClusterAccept::Ok) => true,
|
||||
Ok(ClusterAccept::WithPrejudice) => false,
|
||||
Err(ClusterRejectIncoming::ExcessiveSeconded) => return Err(COST_EXCESSIVE_SECONDED),
|
||||
Err(ClusterRejectIncoming::CandidateUnknown | ClusterRejectIncoming::Duplicate) =>
|
||||
return Err(COST_UNEXPECTED_STATEMENT_CLUSTER_REJECTED),
|
||||
Err(ClusterRejectIncoming::CandidateUnknown | ClusterRejectIncoming::Duplicate) => {
|
||||
return Err(COST_UNEXPECTED_STATEMENT_CLUSTER_REJECTED)
|
||||
},
|
||||
Err(ClusterRejectIncoming::NotInGroup) => {
|
||||
// sanity: shouldn't be possible; we already filtered this
|
||||
// out above.
|
||||
@@ -1989,12 +1995,13 @@ async fn provide_candidate_to_grid<Context>(
|
||||
for (v, action) in actions {
|
||||
let p = match connected_validator_peer(authorities, per_session, v) {
|
||||
None => continue,
|
||||
Some(p) =>
|
||||
Some(p) => {
|
||||
if peers.get(&p).map_or(false, |d| d.knows_relay_parent(&relay_parent)) {
|
||||
(p, peers.get(&p).expect("Qed, was checked above").protocol_version.into())
|
||||
} else {
|
||||
continue;
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
match action {
|
||||
@@ -2940,8 +2947,9 @@ pub(crate) async fn receive_response(response_manager: &mut ResponseManager) ->
|
||||
/// this API must call `dispatch_requests`.
|
||||
pub(crate) async fn next_retry(request_manager: &mut RequestManager) {
|
||||
match request_manager.next_retry_time() {
|
||||
Some(instant) =>
|
||||
futures_timer::Delay::new(instant.saturating_duration_since(Instant::now())).await,
|
||||
Some(instant) => {
|
||||
futures_timer::Delay::new(instant.saturating_duration_since(Instant::now())).await
|
||||
},
|
||||
None => futures::future::pending().await,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -583,12 +583,13 @@ impl UnhandledResponse {
|
||||
// it could also happen in the case that we had a request in-flight
|
||||
// and the request entry was garbage-collected on outdated relay parent.
|
||||
let entry = match manager.requests.get_mut(&identifier) {
|
||||
None =>
|
||||
None => {
|
||||
return ResponseValidationOutput {
|
||||
requested_peer,
|
||||
reputation_changes: Vec::new(),
|
||||
request_status: CandidateRequestStatus::Outdated,
|
||||
},
|
||||
}
|
||||
},
|
||||
Some(e) => e,
|
||||
};
|
||||
|
||||
@@ -710,8 +711,8 @@ fn validate_complete_response(
|
||||
return invalid_candidate_output(COST_INVALID_RESPONSE);
|
||||
}
|
||||
|
||||
if response.candidate_receipt.descriptor.persisted_validation_data_hash() !=
|
||||
response.persisted_validation_data.hash()
|
||||
if response.candidate_receipt.descriptor.persisted_validation_data_hash()
|
||||
!= response.persisted_validation_data.hash()
|
||||
{
|
||||
return invalid_candidate_output(COST_INVALID_RESPONSE);
|
||||
}
|
||||
@@ -730,8 +731,8 @@ fn validate_complete_response(
|
||||
let candidate_hash = response.candidate_receipt.hash();
|
||||
|
||||
// V2 descriptors are invalid if not enabled by runtime.
|
||||
if !allow_v2_descriptors &&
|
||||
response.candidate_receipt.descriptor.version() == CandidateDescriptorVersion::V2
|
||||
if !allow_v2_descriptors
|
||||
&& response.candidate_receipt.descriptor.version() == CandidateDescriptorVersion::V2
|
||||
{
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
@@ -794,8 +795,8 @@ fn validate_complete_response(
|
||||
};
|
||||
|
||||
// ensure statement is on the correct candidate hash.
|
||||
if unchecked_statement.unchecked_payload().candidate_hash() !=
|
||||
&identifier.candidate_hash
|
||||
if unchecked_statement.unchecked_payload().candidate_hash()
|
||||
!= &identifier.candidate_hash
|
||||
{
|
||||
rep_changes.push((requested_peer, COST_UNREQUESTED_RESPONSE_STATEMENT));
|
||||
continue;
|
||||
|
||||
@@ -914,7 +914,7 @@ fn next_group_index(
|
||||
group_size: usize,
|
||||
) -> GroupIndex {
|
||||
let next_group = group_index.0 + 1;
|
||||
let num_groups =
|
||||
validator_count / group_size + if !validator_count.is_multiple_of(group_size) { 1 } else { 0 };
|
||||
let num_groups = validator_count / group_size
|
||||
+ if !validator_count.is_multiple_of(group_size) { 1 } else { 0 };
|
||||
GroupIndex::from(next_group % num_groups as u32)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user