Skip to content

Commit e904c7f

Browse files
committed
Fix relevant AI code review suggestions
These are for an older PR: #8741 https://gist.github.com/david-crespo/a84474b432090316fa3efcb41335cc24
1 parent 2dc68a0 commit e904c7f

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

trust-quorum/src/coordinator_state.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,14 @@ impl CoordinatorState {
211211
#[expect(unused)]
212212
CoordinatorOperation::CollectLrtqShares { members, shares } => {}
213213
CoordinatorOperation::Prepare { prepares, .. } => {
214-
for (platform_id, (config, share)) in
215-
prepares.clone().into_iter()
216-
{
214+
for (platform_id, (config, share)) in prepares.iter() {
217215
if ctx.connected().contains(&platform_id) {
218216
ctx.send(
219-
platform_id,
220-
PeerMsgKind::Prepare { config, share },
217+
platform_id.clone(),
218+
PeerMsgKind::Prepare {
219+
config: config.clone(),
220+
share: share.clone(),
221+
},
221222
);
222223
}
223224
}
@@ -241,7 +242,6 @@ impl CoordinatorState {
241242
} => {}
242243
CoordinatorOperation::CollectLrtqShares { members, shares } => {}
243244
CoordinatorOperation::Prepare { prepares, prepare_acks } => {
244-
let rack_id = self.reconfigure_msg.rack_id();
245245
if let Some((config, share)) = prepares.get(&to) {
246246
ctx.send(
247247
to,

trust-quorum/src/node.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,16 @@ impl Node {
568568
return;
569569
}
570570

571+
if !config.members.contains_key(ctx.platform_id()) {
572+
error!(
573+
self.log,
574+
"Received Prepare when not a member of configuration";
575+
"from" => %from,
576+
"prepare_epoch" => %config.epoch
577+
);
578+
return;
579+
}
580+
571581
// We always save the config and share if we haven't committed a later
572582
// configuration. If we have seen a newer `Prepare`, it's possible
573583
// that that configuration will not commit, and the latest committed
@@ -594,7 +604,10 @@ impl Node {
594604
);
595605
}
596606
// If we are coordinating for an older epoch, then we should stop
597-
// coordinating. This epoch will never commit.
607+
// coordinating. The configuration at this epoch will either never
608+
// commit, or has already committed without us learning about it from
609+
// Nexus. In either case the rest of the system has moved on and we
610+
// should stop coordinating.
598611
if let Some(cs) = &self.coordinator_state {
599612
if msg_epoch > cs.reconfigure_msg().epoch() {
600613
// This prepare is for a newer configuration than the one we are

0 commit comments

Comments
 (0)