Skip to content

Commit c976a91

Browse files
committed
feat: Add support for SEV chip id to ic-prep
1 parent de88e36 commit c976a91

File tree

11 files changed

+27
-1
lines changed

11 files changed

+27
-1
lines changed

Cargo.lock

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

rs/ic_os/launch-single-vm/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ fn main() {
119119
.unwrap(),
120120
node_operator_principal_id: None,
121121
secret_key_store: None,
122+
chip_id: vec![],
122123
},
123124
)]);
124125

rs/prep/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ DEPENDENCIES = [
2828
"@crate_index//:chrono",
2929
"@crate_index//:clap",
3030
"@crate_index//:fs_extra",
31+
"@crate_index//:hex",
3132
"@crate_index//:json5",
3233
"@crate_index//:maplit",
3334
"@crate_index//:openssl",

rs/prep/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ base64 = "0.11"
99
clap = { version = "3.1.6", features = ["derive"] }
1010
chrono = "0.4.19"
1111
fs_extra = "1.2.0"
12+
hex = "0.4"
1213
ic-crypto = { path = "../crypto" }
1314
ic-crypto-node-key-generation = { path = "../crypto/node_key_generation" }
1415
ic-crypto-node-key-validation = { path = "../crypto/node_key_validation" }

rs/prep/src/bin/prep.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,12 @@ fn parse_nodes_deprecated(src: &str) -> Result<Node> {
381381
// P2P is special, and needs a custom protocol
382382
let p2p_addr: Url = format!("org.internetcomputer.p2p1://{}", parts[2]).parse()?;
383383

384+
// chip_id is optional
385+
let mut chip_id = vec![];
386+
if parts.len() > 6 {
387+
chip_id = hex::decode(parts[6])?;
388+
}
389+
384390
Ok(Node {
385391
node_index,
386392
subnet_index,
@@ -390,6 +396,7 @@ fn parse_nodes_deprecated(src: &str) -> Result<Node> {
390396
p2p_addr: ConnectionEndpoint::try_from(p2p_addr)?,
391397
node_operator_principal_id: None,
392398
secret_key_store: None,
399+
chip_id,
393400
},
394401
})
395402
}
@@ -404,6 +411,7 @@ struct NodeFlag {
404411
pub public_api: Option<ConnectionEndpoint>,
405412
/// The initial endpoint that P2P uses.
406413
pub p2p_addr: Option<ConnectionEndpoint>,
414+
pub chip_id: Option<Vec<u8>>,
407415
}
408416

409417
#[derive(Error, Clone, Debug, PartialEq)]
@@ -444,6 +452,7 @@ impl TryFrom<NodeFlag> for Node {
444452
let xnet_api = value.xnet_api.ok_or(MissingFieldError::Xnet)?;
445453
let public_api = value.public_api.ok_or(MissingFieldError::PublicApi)?;
446454
let p2p_addr = value.p2p_addr.ok_or(MissingFieldError::P2PAddr)?;
455+
let chip_id = value.chip_id.unwrap_or_default();
447456

448457
Ok(Self {
449458
node_index,
@@ -454,6 +463,7 @@ impl TryFrom<NodeFlag> for Node {
454463
p2p_addr,
455464
node_operator_principal_id: None,
456465
secret_key_store: None,
466+
chip_id,
457467
},
458468
})
459469
}
@@ -805,6 +815,7 @@ mod test_flag_nodes_parser_deprecated {
805815
p2p_addr: "org.internetcomputer.p2p1://1.2.3.4:80".parse().unwrap(),
806816
node_operator_principal_id: None,
807817
secret_key_store: None,
818+
chip_id: vec![],
808819
},
809820
};
810821

@@ -825,6 +836,7 @@ mod test_flag_nodes_parser_deprecated {
825836
p2p_addr: "org.internetcomputer.p2p1://1.2.3.4:80".parse().unwrap(),
826837
node_operator_principal_id: None,
827838
secret_key_store: None,
839+
chip_id: vec![],
828840
},
829841
};
830842

@@ -853,6 +865,7 @@ mod test_flag_node_parser {
853865
p2p_addr: "org.internetcomputer.p2p1://1.2.3.4:80".parse().unwrap(),
854866
node_operator_principal_id: None,
855867
secret_key_store: None,
868+
chip_id: vec![],
856869
},
857870
};
858871

rs/prep/src/node.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ pub struct NodeConfiguration {
201201
/// The principal id of the node operator that operates this node.
202202
pub node_operator_principal_id: Option<PrincipalId>,
203203

204-
/// If set, the specified secret key store will be used. Ohterwise, a new
204+
/// If set, the specified secret key store will be used. Otherwise, a new
205205
/// one will be created when initializing the internet computer.
206206
///
207207
/// Creating the secret key store ahead of time allows for the node id to be
@@ -212,6 +212,9 @@ pub struct NodeConfiguration {
212212
/// directory chosen by ic-prep.
213213
#[serde(skip_serializing, skip_deserializing)]
214214
pub secret_key_store: Option<NodeSecretKeyStore>,
215+
216+
/// The SEV-SNP chip_identifier for this node.
217+
pub chip_id: Vec<u8>,
215218
}
216219

217220
#[derive(Error, Debug)]
@@ -388,6 +391,7 @@ mod node_configuration {
388391
p2p_addr: "org.internetcomputer.p2p1://1.2.3.4:1234".parse().unwrap(),
389392
node_operator_principal_id: None,
390393
secret_key_store: None,
394+
chip_id: vec![],
391395
};
392396

393397
let got = pbNodeRecord::try_from(node_configuration).unwrap();

rs/prep/src/prep_state_directory.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ mod tests {
126126
p2p_addr: "org.internetcomputer.p2p1://1.2.3.4:4".parse()?,
127127
node_operator_principal_id: None,
128128
secret_key_store: None,
129+
chip_id: vec![],
129130
},
130131
);
131132

rs/registry/regedit/src/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ pub fn run_ic_prep() -> (TempDir, IcPrepStateDir) {
134134
.expect("can't fail"),
135135
node_operator_principal_id: None,
136136
secret_key_store: None,
137+
chip_id: vec![],
137138
},
138139
);
139140

rs/replica_tests/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ pub fn get_ic_config() -> IcConfig {
241241
.expect("can't fail"),
242242
node_operator_principal_id: None,
243243
secret_key_store: Some(node_sks),
244+
chip_id: vec![],
244245
},
245246
);
246247

rs/starter/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ fn main() -> Result<()> {
9595
.expect("can't fail"),
9696
node_operator_principal_id: None,
9797
secret_key_store: None,
98+
chip_id: vec![],
9899
},
99100
);
100101

0 commit comments

Comments
 (0)