Skip to content

Commit 0ca88b1

Browse files
committed
Do not allow commits on expunged nodes
1 parent 665ef30 commit 0ca88b1

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

trust-quorum/src/node.rs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,10 @@ impl Node {
101101
};
102102

103103
if let Some(kcs) = &self.key_share_computer {
104-
// We know from our `ValidatedReconfigureMsg` that we haven't seen a newer
105-
// configuration and we have the correct last committed configuration. Therefore if we are computing a key share,
106-
// we must be doing it for a stale commit and should cancel it.
104+
// We know from our `ValidatedReconfigureMsg` that we haven't seen
105+
// a newer configuration and we have the correct last committed
106+
// configuration. Therefore if we are computing a key share, we must
107+
// be doing it for a stale commit and should cancel it.
107108
//
108109
// I don't think it's actually possible to hit this condition, but
109110
// we check anyway.
@@ -139,6 +140,19 @@ impl Node {
139140
{
140141
let ps = ctx.persistent_state();
141142

143+
if let Some(expunged) = &ps.expunged {
144+
error!(
145+
self.log,
146+
"Commit attempted on expunged node";
147+
"expunged_epoch" => %expunged.epoch,
148+
"expunging_node" => %expunged.from
149+
);
150+
return Err(CommitError::Expunged {
151+
epoch: expunged.epoch,
152+
from: expunged.from.clone(),
153+
});
154+
}
155+
142156
// If we have a configuration the rack id must match the one from
143157
// Nexus
144158
if let Some(ps_rack_id) = ps.rack_id() {
@@ -385,6 +399,10 @@ impl Node {
385399
ps.expunged = Some(ExpungedMetadata { epoch, from });
386400
true
387401
});
402+
403+
// Stop coordinating and computing a key share
404+
self.coordinator_state = None;
405+
self.key_share_computer = None;
388406
} else {
389407
let m = concat!(
390408
"Received Expunge message, but we have no configurations. ",
@@ -820,6 +838,8 @@ pub enum CommitError {
820838
),
821839
#[error("cannot commit: not prepared for epoch {0}")]
822840
NotPrepared(Epoch),
841+
#[error("cannot commit: expunged at epoch {epoch} by {from}")]
842+
Expunged { epoch: Epoch, from: PlatformId },
823843
}
824844

825845
#[cfg(test)]

0 commit comments

Comments
 (0)