Skip to content

Commit 83f7f06

Browse files
authored
TQ: Use BaseboardId instead of PlatformId (#9121)
PlatformId was used as an internal placeholder during trust quorum protocol development. In order to integrate the trust quorum protocol code into the rest of Omicron we need to use the proper `BaseboardId` type from `sled-agent-types`. The real `PlatformId` comes from the `dice-util-msgs` crate and we'll need to be able to compare that `PlatfromId` with `BaseboardId` and convert from `PlatformId` to `BaseboardId` in the future.
1 parent 42f4233 commit 83f7f06

File tree

21 files changed

+222
-222
lines changed

21 files changed

+222
-222
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sled-agent/types/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ async-trait.workspace = true
1313
bootstore.workspace = true
1414
camino.workspace = true
1515
chrono.workspace = true
16+
daft.workspace = true
1617
iddqd.workspace = true
1718
nexus-sled-agent-shared.workspace = true
1819
# Note: we're trying to avoid a dependency from sled-agent-types to nexus-types

sled-agent/types/src/sled.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use std::net::{IpAddr, Ipv6Addr, SocketAddrV6};
88

99
use async_trait::async_trait;
10+
use daft::Diffable;
1011
use omicron_common::{
1112
address::{self, Ipv6Subnet, SLED_PREFIX},
1213
ledger::Ledgerable,
@@ -22,14 +23,33 @@ pub const SWITCH_ZONE_BASEBOARD_FILE: &str = "/opt/oxide/baseboard.json";
2223
/// A representation of a Baseboard ID as used in the inventory subsystem
2324
/// This type is essentially the same as a `Baseboard` except it doesn't have a
2425
/// revision or HW type (Gimlet, PC, Unknown).
25-
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema)]
26+
#[derive(
27+
Clone,
28+
Debug,
29+
Serialize,
30+
Deserialize,
31+
PartialEq,
32+
Eq,
33+
PartialOrd,
34+
Ord,
35+
Hash,
36+
JsonSchema,
37+
Diffable,
38+
)]
39+
#[daft(leaf)]
2640
pub struct BaseboardId {
2741
/// Oxide Part Number
2842
pub part_number: String,
2943
/// Serial number (unique for a given part number)
3044
pub serial_number: String,
3145
}
3246

47+
impl std::fmt::Display for BaseboardId {
48+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
49+
write!(f, "{}:{}", self.part_number, self.serial_number)
50+
}
51+
}
52+
3353
/// A request to Add a given sled after rack initialization has occurred
3454
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema)]
3555
pub struct AddSledRequest {

trust-quorum/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ secrecy.workspace = true
2525
serde.workspace = true
2626
serde_with.workspace = true
2727
sha3.workspace = true
28+
sled-agent-types.workspace = true
2829
slog.workspace = true
2930
slog-error-chain.workspace = true
3031
static_assertions.workspace = true

trust-quorum/src/alarm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub enum Alarm {
2727
MismatchedConfigurations {
2828
config1: Configuration,
2929
config2: Configuration,
30-
// Either a stringified `PlatformId` or "Nexus"
30+
// Either a stringified `BaseboardId` or "Nexus"
3131
from: String,
3232
},
3333

trust-quorum/src/compute_key_share.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//! other nodes so that it can compute its own key share.
1010
1111
use crate::{
12-
Alarm, Configuration, Epoch, NodeHandlerCtx, PeerMsgKind, PlatformId,
12+
Alarm, BaseboardId, Configuration, Epoch, NodeHandlerCtx, PeerMsgKind,
1313
};
1414
use gfss::gf256::Gf256;
1515
use gfss::shamir::{self, Share};
@@ -25,7 +25,7 @@ pub struct KeyShareComputer {
2525
// A copy of the configuration stored in persistent state
2626
config: Configuration,
2727

28-
collected_shares: BTreeMap<PlatformId, Share>,
28+
collected_shares: BTreeMap<BaseboardId, Share>,
2929
}
3030

3131
#[cfg(feature = "danger_partial_eq_ct_wrapper")]
@@ -63,7 +63,7 @@ impl KeyShareComputer {
6363
pub fn on_connect(
6464
&mut self,
6565
ctx: &mut impl NodeHandlerCtx,
66-
peer: PlatformId,
66+
peer: BaseboardId,
6767
) {
6868
if self.config.members.contains_key(&peer)
6969
&& !self.collected_shares.contains_key(&peer)
@@ -79,7 +79,7 @@ impl KeyShareComputer {
7979
pub fn handle_share(
8080
&mut self,
8181
ctx: &mut impl NodeHandlerCtx,
82-
from: PlatformId,
82+
from: BaseboardId,
8383
epoch: Epoch,
8484
share: Share,
8585
) -> bool {

trust-quorum/src/configuration.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! A configuration of a trust quroum at a given epoch
66
77
use crate::crypto::{EncryptedRackSecrets, RackSecret, Sha3_256Digest};
8-
use crate::{Epoch, PlatformId, Threshold};
8+
use crate::{BaseboardId, Epoch, Threshold};
99
use daft::Diffable;
1010
use gfss::shamir::{Share, SplitError};
1111
use iddqd::{IdOrdItem, id_upcast};
@@ -51,11 +51,11 @@ pub struct Configuration {
5151
pub epoch: Epoch,
5252

5353
/// Who was the coordinator of this reconfiguration?
54-
pub coordinator: PlatformId,
54+
pub coordinator: BaseboardId,
5555

5656
// All members of the current configuration and the hash of their key shares
5757
#[serde_as(as = "Vec<(_, _)>")]
58-
pub members: BTreeMap<PlatformId, Sha3_256Digest>,
58+
pub members: BTreeMap<BaseboardId, Sha3_256Digest>,
5959

6060
/// The number of sleds required to reconstruct the rack secret
6161
pub threshold: Threshold,
@@ -77,9 +77,9 @@ impl IdOrdItem for Configuration {
7777
pub struct NewConfigParams<'a> {
7878
pub rack_id: RackUuid,
7979
pub epoch: Epoch,
80-
pub members: &'a BTreeSet<PlatformId>,
80+
pub members: &'a BTreeSet<BaseboardId>,
8181
pub threshold: Threshold,
82-
pub coordinator_id: &'a PlatformId,
82+
pub coordinator_id: &'a BaseboardId,
8383
}
8484

8585
impl Configuration {
@@ -90,7 +90,7 @@ impl Configuration {
9090
/// the last committed epoch.
9191
pub fn new(
9292
params: NewConfigParams<'_>,
93-
) -> Result<(Configuration, BTreeMap<PlatformId, Share>), ConfigurationError>
93+
) -> Result<(Configuration, BTreeMap<BaseboardId, Share>), ConfigurationError>
9494
{
9595
let coordinator = params.coordinator_id.clone();
9696
let rack_secret = RackSecret::new();
@@ -110,8 +110,9 @@ impl Configuration {
110110
(s.clone(), digest)
111111
});
112112

113-
let mut members: BTreeMap<PlatformId, Sha3_256Digest> = BTreeMap::new();
114-
let mut shares: BTreeMap<PlatformId, Share> = BTreeMap::new();
113+
let mut members: BTreeMap<BaseboardId, Sha3_256Digest> =
114+
BTreeMap::new();
115+
let mut shares: BTreeMap<BaseboardId, Share> = BTreeMap::new();
115116
for (platform_id, (share, digest)) in
116117
params.members.iter().cloned().zip(shares_and_digests)
117118
{

trust-quorum/src/coordinator_state.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::crypto::{LrtqShare, PlaintextRackSecrets, ReconstructedRackSecret};
1010
use crate::validators::{
1111
ReconfigurationError, ValidatedLrtqUpgradeMsg, ValidatedReconfigureMsg,
1212
};
13-
use crate::{Configuration, Epoch, PeerMsgKind, PlatformId, RackSecret};
13+
use crate::{BaseboardId, Configuration, Epoch, PeerMsgKind, RackSecret};
1414
use bootstore::trust_quorum::RackSecret as LrtqRackSecret;
1515
use daft::{Diffable, Leaf};
1616
use gfss::shamir::Share;
@@ -302,7 +302,7 @@ impl CoordinatorState {
302302
pub fn send_msgs_to(
303303
&mut self,
304304
ctx: &mut impl NodeHandlerCtx,
305-
to: PlatformId,
305+
to: BaseboardId,
306306
) {
307307
match &self.op {
308308
CoordinatorOperation::CollectShares {
@@ -349,7 +349,7 @@ impl CoordinatorState {
349349

350350
/// Record a `PrepareAck` from another node as part of tracking
351351
/// quorum for the prepare phase of the trust quorum protocol.
352-
pub fn ack_prepare(&mut self, from: PlatformId) {
352+
pub fn ack_prepare(&mut self, from: BaseboardId) {
353353
match &mut self.op {
354354
CoordinatorOperation::Prepare {
355355
prepares, prepare_acks, ..
@@ -384,7 +384,7 @@ impl CoordinatorState {
384384
pub fn handle_share(
385385
&mut self,
386386
ctx: &mut impl NodeHandlerCtx,
387-
from: PlatformId,
387+
from: BaseboardId,
388388
epoch: Epoch,
389389
share: Share,
390390
) {
@@ -501,7 +501,7 @@ impl CoordinatorState {
501501
pub fn handle_lrtq_share(
502502
&mut self,
503503
ctx: &mut impl NodeHandlerCtx,
504-
from: PlatformId,
504+
from: BaseboardId,
505505
share: LrtqShare,
506506
) {
507507
match &mut self.op {
@@ -627,7 +627,7 @@ impl CoordinatorState {
627627
&mut self,
628628
ctx: &mut impl NodeHandlerCtx,
629629
log: Logger,
630-
mut new_shares: BTreeMap<PlatformId, Share>,
630+
mut new_shares: BTreeMap<BaseboardId, Share>,
631631
plaintext_secrets: PlaintextRackSecrets,
632632
) {
633633
let new_epoch = self.configuration.epoch;
@@ -714,25 +714,25 @@ impl CoordinatorState {
714714
pub enum CoordinatorOperation {
715715
CollectShares {
716716
old_epoch: Epoch,
717-
old_collected_shares: BTreeMap<PlatformId, Share>,
717+
old_collected_shares: BTreeMap<BaseboardId, Share>,
718718

719719
// These are new shares that the coordinator created that we carry along
720720
// until we get to `CoordinatorOperation::Prepare`
721-
new_shares: BTreeMap<PlatformId, Share>,
721+
new_shares: BTreeMap<BaseboardId, Share>,
722722
},
723723
CollectLrtqShares {
724-
collected_lrtq_shares: BTreeMap<PlatformId, LrtqShare>,
724+
collected_lrtq_shares: BTreeMap<BaseboardId, LrtqShare>,
725725

726726
// These are new shares that the coordinator created that we carry along
727727
// until we get to `CoordinatorOperation::Prepare`
728-
new_shares: BTreeMap<PlatformId, Share>,
728+
new_shares: BTreeMap<BaseboardId, Share>,
729729
},
730730
Prepare {
731731
/// The set of Prepares to send to each node
732-
prepares: BTreeMap<PlatformId, (Configuration, Share)>,
732+
prepares: BTreeMap<BaseboardId, (Configuration, Share)>,
733733

734734
/// Acknowledgements that the prepare has been received
735-
prepare_acks: BTreeSet<PlatformId>,
735+
prepare_acks: BTreeSet<BaseboardId>,
736736
},
737737
}
738738

@@ -749,7 +749,7 @@ impl CoordinatorOperation {
749749

750750
/// Return the members that have acked prepares, if the current operation
751751
/// is `Prepare`. Otherwise return an empty set.
752-
pub fn acked_prepares(&self) -> BTreeSet<PlatformId> {
752+
pub fn acked_prepares(&self) -> BTreeSet<BaseboardId> {
753753
if let CoordinatorOperation::Prepare { prepare_acks, .. } = self {
754754
prepare_acks.clone()
755755
} else {

trust-quorum/src/lib.rs

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use daft::Diffable;
1414
use derive_more::Display;
1515
use gfss::shamir::Share;
1616
use serde::{Deserialize, Serialize};
17+
pub use sled_agent_types::sled::BaseboardId;
1718
use slog::{Logger, error, warn};
1819

1920
mod compute_key_share;
@@ -91,57 +92,13 @@ impl Epoch {
9192
#[daft(leaf)]
9293
pub struct Threshold(pub u8);
9394

94-
/// A unique identifier for a given trust quorum member.
95-
//
96-
/// This data is derived from the subject common name in the platform identity
97-
/// certificate that makes up part of the certificate chain used to establish
98-
/// [sprockets](https://github.com/oxidecomputer/sprockets) connections.
99-
///
100-
/// See RFDs 303 and 308 for more details.
101-
#[derive(
102-
Debug,
103-
Clone,
104-
PartialEq,
105-
Eq,
106-
PartialOrd,
107-
Ord,
108-
Serialize,
109-
Deserialize,
110-
Diffable,
111-
)]
112-
#[daft(leaf)]
113-
pub struct PlatformId {
114-
part_number: String,
115-
serial_number: String,
116-
}
117-
118-
impl std::fmt::Display for PlatformId {
119-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
120-
write!(f, "{}:{}", self.part_number, self.serial_number)
121-
}
122-
}
123-
124-
impl PlatformId {
125-
pub fn new(part_number: String, serial_number: String) -> PlatformId {
126-
PlatformId { part_number, serial_number }
127-
}
128-
129-
pub fn part_number(&self) -> &str {
130-
&self.part_number
131-
}
132-
133-
pub fn serial_number(&self) -> &str {
134-
&self.serial_number
135-
}
136-
}
137-
13895
/// A container to make messages between trust quorum nodes routable
13996
#[derive(Debug, Clone, Serialize, Deserialize, Diffable)]
14097
#[cfg_attr(feature = "danger_partial_eq_ct_wrapper", derive(PartialEq, Eq))]
14198
#[daft(leaf)]
14299
pub struct Envelope {
143-
pub to: PlatformId,
144-
pub from: PlatformId,
100+
pub to: BaseboardId,
101+
pub from: BaseboardId,
145102
pub msg: PeerMsg,
146103
}
147104

@@ -160,7 +117,7 @@ impl Envelope {
160117
pub fn validate_share(
161118
log: &Logger,
162119
config: &Configuration,
163-
from: &PlatformId,
120+
from: &BaseboardId,
164121
epoch: Epoch,
165122
share: &Share,
166123
) -> bool {

trust-quorum/src/messages.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! Messsages for the trust quorum protocol
66
77
use crate::crypto::LrtqShare;
8-
use crate::{Configuration, Epoch, PlatformId, Threshold};
8+
use crate::{BaseboardId, Configuration, Epoch, Threshold};
99
use gfss::shamir::Share;
1010
use omicron_uuid_kinds::RackUuid;
1111
use serde::{Deserialize, Serialize};
@@ -18,7 +18,7 @@ pub struct ReconfigureMsg {
1818
pub rack_id: RackUuid,
1919
pub epoch: Epoch,
2020
pub last_committed_epoch: Option<Epoch>,
21-
pub members: BTreeSet<PlatformId>,
21+
pub members: BTreeSet<BaseboardId>,
2222
pub threshold: Threshold,
2323
}
2424

@@ -32,7 +32,7 @@ pub struct LrtqUpgradeMsg {
3232
// upgraded trust quorum cluster. This is implicit, as the membership of the
3333
// LRTQ cluster is computed based on the existing control plane sleds known
3434
// to Nexus.
35-
pub members: BTreeSet<PlatformId>,
35+
pub members: BTreeSet<BaseboardId>,
3636
pub threshold: Threshold,
3737
}
3838

0 commit comments

Comments
 (0)