Skip to content

Commit 66558af

Browse files
paritytech-release-backport-bot[bot]tdimitrovgithub-actions[bot]
authored
[stable2509] Backport #10163 (#10167)
Backport #10163 into `stable2509` from tdimitrov. See the [documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md) on how to use this bot. <!-- # To be used by other automation, do not modify: original-pr-number: #${pull_number} --> Co-authored-by: Tsvetomir Dimitrov <[email protected]> Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 5cb165c commit 66558af

File tree

2 files changed

+67
-31
lines changed

2 files changed

+67
-31
lines changed

polkadot/node/network/collator-protocol/src/validator_side/mod.rs

Lines changed: 60 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,17 @@ struct GroupAssignments {
348348
current: Vec<ParaId>,
349349
}
350350

351+
/// Represents the result from a hold off operation.
352+
enum HoldOffOperationOutcome {
353+
/// The advertisement was held off and this is the first hold off for the relay parent.
354+
FirstHoldOff,
355+
/// The advertisement was held off and this is a subsequent hold off for this relay parent.
356+
SubsequentHoldOff,
357+
/// The advertisement was not held off. The hold off period for this relay parent has already
358+
/// expired.
359+
NoHoldOff,
360+
}
361+
351362
/// Represents the hold off state of a relay parent.
352363
enum RelayParentHoldOffState {
353364
/// No Advertisements from non-invulnerable collators were received so far. Nothing was held
@@ -390,17 +401,20 @@ impl RelayParentHoldOffState {
390401
/// Holds off the advertisement, if nothing was held off for this relay parent or there are
391402
/// other advertisements being held off. Return false if the hold off was complete for the
392403
/// relay parent.
393-
fn hold_off_if_necessary(&mut self, advertisement: HeldOffAdvertisement) -> bool {
404+
fn hold_off_if_necessary(
405+
&mut self,
406+
advertisement: HeldOffAdvertisement,
407+
) -> HoldOffOperationOutcome {
394408
match self {
395409
Self::NotStarted => {
396410
*self = Self::HoldingOff(vec![advertisement].into());
397-
true
411+
HoldOffOperationOutcome::FirstHoldOff
398412
},
399413
Self::HoldingOff(advertisements) => {
400414
advertisements.push_back(advertisement);
401-
true
415+
HoldOffOperationOutcome::SubsequentHoldOff
402416
},
403-
Self::Done => false,
417+
Self::Done => HoldOffOperationOutcome::NoHoldOff,
404418
}
405419
}
406420
}
@@ -1069,36 +1083,51 @@ fn hold_off_asset_hub_collation_if_needed(
10691083
return false
10701084
};
10711085

1072-
if rp_state.ah_held_off_advertisements.hold_off_if_necessary(HeldOffAdvertisement {
1073-
relay_parent,
1074-
peer_id,
1075-
collator_id,
1076-
prospective_candidate,
1077-
}) {
1078-
state.ah_held_off_rp_timers.push(Box::pin(async move {
1079-
Delay::new(hold_off_duration).await;
1080-
relay_parent
1081-
}));
1086+
let hold_off_outcome =
1087+
rp_state.ah_held_off_advertisements.hold_off_if_necessary(HeldOffAdvertisement {
1088+
relay_parent,
1089+
peer_id,
1090+
collator_id,
1091+
prospective_candidate,
1092+
});
10821093

1083-
gum::debug!(
1084-
target: LOG_TARGET,
1085-
?peer_id,
1086-
?relay_parent,
1087-
?prospective_candidate,
1088-
"AssetHub collation held off, not from invulnerable collator",
1089-
);
1094+
match hold_off_outcome {
1095+
HoldOffOperationOutcome::FirstHoldOff => {
1096+
state.ah_held_off_rp_timers.push(Box::pin(async move {
1097+
Delay::new(hold_off_duration).await;
1098+
relay_parent
1099+
}));
10901100

1091-
return true;
1092-
} else {
1093-
gum::debug!(
1094-
target: LOG_TARGET,
1095-
?peer_id,
1096-
?relay_parent,
1097-
?prospective_candidate,
1098-
"AssetHub collation from non-invulnerable collator not held off - already done for this relay parent",
1099-
);
1101+
gum::debug!(
1102+
target: LOG_TARGET,
1103+
?peer_id,
1104+
?relay_parent,
1105+
?prospective_candidate,
1106+
"AssetHub collation held off, not from invulnerable collator. First hold off.",
1107+
);
11001108

1101-
return false
1109+
true
1110+
},
1111+
HoldOffOperationOutcome::SubsequentHoldOff => {
1112+
gum::debug!(
1113+
target: LOG_TARGET,
1114+
?peer_id,
1115+
?relay_parent,
1116+
?prospective_candidate,
1117+
"AssetHub collation held off, not from invulnerable collator. Subsequent hold off.",
1118+
);
1119+
true
1120+
},
1121+
HoldOffOperationOutcome::NoHoldOff => {
1122+
gum::debug!(
1123+
target: LOG_TARGET,
1124+
?peer_id,
1125+
?relay_parent,
1126+
?prospective_candidate,
1127+
"AssetHub collation from non-invulnerable collator not held off - already done for this relay parent",
1128+
);
1129+
false
1130+
},
11021131
}
11031132
}
11041133

prdoc/pr_10163.prdoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
title: Better hadling of held off collations for AHM stop-gap solution
2+
doc:
3+
- audience: Node Dev
4+
description: Make logging around held off AHM collations better.
5+
crates:
6+
- name: polkadot-collator-protocol
7+
bump: patch

0 commit comments

Comments
 (0)