From ab4f934d3079ae53423ee7d2089093e2830ad070 Mon Sep 17 00:00:00 2001 From: Rain Date: Wed, 4 Mar 2026 20:29:54 -0800 Subject: [PATCH] [spr] initial version Created using spr 1.3.6-beta.1 --- Cargo.lock | 23 ++++++++++++++----- Cargo.toml | 2 +- common/Cargo.toml | 1 - common/src/lib.rs | 5 ++++ sled-agent/Cargo.toml | 1 - sled-agent/types/Cargo.toml | 2 +- sled-agent/types/src/boot_disk.rs | 5 ++-- sled-agent/types/versions/Cargo.toml | 2 +- .../src/add_rot_attestation/attestation.rs | 12 +++++++--- .../add_trust_quorum_status/trust_quorum.rs | 4 +++- trust-quorum/types/versions/Cargo.toml | 2 +- .../types/versions/src/initial/crypto.rs | 8 +++++-- 12 files changed, 46 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9f0bb09c3f1..9ddf162a0c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -935,6 +935,19 @@ version = "3.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" +[[package]] +name = "byte-wrapper" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b041d2328ab2041b4e9d8f21e3b0b5b8bb61e9a23bb9171387771c314ea340" +dependencies = [ + "base64 0.22.1", + "hex", + "schemars 0.8.22", + "serde_core", + "serde_json", +] + [[package]] name = "bytecount" version = "0.6.9" @@ -8237,7 +8250,6 @@ dependencies = [ "schemars 0.8.22", "semver 1.0.27", "serde", - "serde_human_bytes", "serde_json", "serde_urlencoded", "serde_with", @@ -9038,7 +9050,6 @@ dependencies = [ "schemars 0.8.22", "secrecy 0.10.3", "serde", - "serde_human_bytes", "serde_json", "sha2", "sha3", @@ -13404,6 +13415,7 @@ dependencies = [ "anyhow", "async-trait", "bootstore", + "byte-wrapper", "camino", "camino-tempfile", "chrono", @@ -13418,7 +13430,6 @@ dependencies = [ "rcgen", "schemars 0.8.22", "serde", - "serde_human_bytes", "serde_json", "sled-agent-types-versions", "sled-hardware-types", @@ -13440,6 +13451,7 @@ dependencies = [ "anyhow", "async-trait", "bootstore", + "byte-wrapper", "camino", "chrono", "daft", @@ -13456,7 +13468,6 @@ dependencies = [ "proptest", "schemars 0.8.22", "serde", - "serde_human_bytes", "serde_json", "serde_with", "sha3", @@ -13802,7 +13813,7 @@ version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1c97747dbf44bb1ca44a561ece23508e99cb592e862f22222dcf42f51d1e451" dependencies = [ - "heck 0.4.1", + "heck 0.5.0", "proc-macro2", "quote", "syn 2.0.117", @@ -15452,6 +15463,7 @@ dependencies = [ name = "trust-quorum-types-versions" version = "0.1.0" dependencies = [ + "byte-wrapper", "daft", "derive_more 0.99.20", "gfss", @@ -15461,7 +15473,6 @@ dependencies = [ "rand 0.9.2", "schemars 0.8.22", "serde", - "serde_human_bytes", "serde_with", "sled-hardware-types", "slog", diff --git a/Cargo.toml b/Cargo.toml index c9c9abe8611..c3ceb79e26d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -419,6 +419,7 @@ bootstrap-agent-client = { path = "clients/bootstrap-agent-client" } bootstrap-agent-lockstep-client = { path = "clients/bootstrap-agent-lockstep-client" } buf-list = { version = "1.0.3", features = ["tokio1"] } byteorder = "1.5.0" +byte-wrapper = { version = "0.1.0", features = ["serde", "schemars08"] } bytes = "1.10.1" camino = { version = "1.2.0", features = ["serde1"] } camino-tempfile = "1.4.1" @@ -744,7 +745,6 @@ semver = { version = "1.0.26", features = ["std", "serde"] } seq-macro = "0.3.6" serde = { version = "1.0", default-features = false, features = [ "derive", "rc" ] } serde_cbor = "0.11.2" -serde_human_bytes = { git = "https://github.com/oxidecomputer/serde_human_bytes", branch = "main" } serde_json = "1.0.145" serde_tokenstream = "0.2" serde_urlencoded = "0.7.1" diff --git a/common/Cargo.toml b/common/Cargo.toml index d7ff06376f2..af239b795ce 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -39,7 +39,6 @@ reqwest = { workspace = true, features = ["rustls", "stream"] } schemars = { workspace = true, features = ["chrono", "semver", "uuid1"] } semver.workspace = true serde.workspace = true -serde_human_bytes.workspace = true serde_json.workspace = true serde_with.workspace = true slog.workspace = true diff --git a/common/src/lib.rs b/common/src/lib.rs index 2b0b7b684d2..1d4dd4cf59f 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -96,6 +96,11 @@ impl std::fmt::Debug for NoDebug { } } +/// Produce an OpenAPI schema describing a hex string of a specific byte length. +/// +/// Used by versioned sled-agent types to preserve schema compatibility. New +/// code should use `byte_wrapper::HexArray` which implements `JsonSchema` +/// directly. pub fn hex_schema( generator: &mut schemars::SchemaGenerator, ) -> schemars::schema::Schema { diff --git a/sled-agent/Cargo.toml b/sled-agent/Cargo.toml index 877e748c523..035405aa01c 100644 --- a/sled-agent/Cargo.toml +++ b/sled-agent/Cargo.toml @@ -86,7 +86,6 @@ reqwest = { workspace = true, features = ["rustls", "stream"] } reqwest012 = { workspace = true } schemars = { workspace = true, features = ["chrono", "uuid1"] } serde.workspace = true -serde_human_bytes.workspace = true serde_json = { workspace = true, features = ["raw_value"] } sha2.workspace = true sha3.workspace = true diff --git a/sled-agent/types/Cargo.toml b/sled-agent/types/Cargo.toml index 6cd3e1e6569..1d65374c825 100644 --- a/sled-agent/types/Cargo.toml +++ b/sled-agent/types/Cargo.toml @@ -11,6 +11,7 @@ workspace = true anyhow.workspace = true async-trait.workspace = true bootstore.workspace = true +byte-wrapper.workspace = true camino.workspace = true chrono.workspace = true daft.workspace = true @@ -22,7 +23,6 @@ oxnet.workspace = true proptest = { workspace = true, optional = true } schemars.workspace = true serde.workspace = true -serde_human_bytes.workspace = true serde_json.workspace = true sled-agent-types-versions.workspace = true sled-hardware-types.workspace = true diff --git a/sled-agent/types/src/boot_disk.rs b/sled-agent/types/src/boot_disk.rs index 30129d6c7e9..a8ff96b4795 100644 --- a/sled-agent/types/src/boot_disk.rs +++ b/sled-agent/types/src/boot_disk.rs @@ -25,10 +25,9 @@ pub struct BootDiskWriteStartQueryParams { pub update_id: Uuid, // TODO do we already have sha2-256 hashes of the OS images, and if so // should we use that instead? Another option is to use the external API - // `Digest` type, although it predates `serde_human_bytes` so just stores + // `Digest` type, although it predates `byte-wrapper` so just stores // the hash as a `String`. - #[serde(with = "serde_human_bytes::hex_array")] - #[schemars(schema_with = "omicron_common::hex_schema::<32>")] + #[serde(with = "byte_wrapper::HexArray::<32>")] pub sha3_256_digest: [u8; 32], } diff --git a/sled-agent/types/versions/Cargo.toml b/sled-agent/types/versions/Cargo.toml index 99dba31abcd..ef3cad4e2d6 100644 --- a/sled-agent/types/versions/Cargo.toml +++ b/sled-agent/types/versions/Cargo.toml @@ -17,6 +17,7 @@ illumos-utils.workspace = true indent_write.workspace = true async-trait.workspace = true bootstore.workspace = true +byte-wrapper.workspace = true omicron-common.workspace = true omicron-passwords.workspace = true omicron-uuid-kinds.workspace = true @@ -28,7 +29,6 @@ proptest = { workspace = true, optional = true } schemars.workspace = true serde.workspace = true serde_with = { workspace = true, features = ["hex", "schemars_0_8"] } -serde_human_bytes.workspace = true serde_json.workspace = true sha3.workspace = true sled-hardware-types.workspace = true diff --git a/sled-agent/types/versions/src/add_rot_attestation/attestation.rs b/sled-agent/types/versions/src/add_rot_attestation/attestation.rs index da718ebde61..3d0944232d7 100644 --- a/sled-agent/types/versions/src/add_rot_attestation/attestation.rs +++ b/sled-agent/types/versions/src/add_rot_attestation/attestation.rs @@ -31,7 +31,9 @@ const SHA3_256_LEN: usize = 32; #[derive(Deserialize, Serialize, JsonSchema)] #[serde(transparent)] pub struct Sha3_256Digest( - #[serde(with = "serde_human_bytes::hex_array")] + #[serde(with = "byte_wrapper::HexArray::")] + // If and when this type changes next, delete the `schemars(schema_with)` + // line and this comment. #[schemars(schema_with = "omicron_common::hex_schema::")] pub [u8; SHA3_256_LEN], ); @@ -68,7 +70,9 @@ pub struct CertificateChain(pub Vec); #[serde(untagged)] pub enum Nonce { /// A 32-byte nonce. - #[serde(with = "serde_human_bytes::hex_array")] + #[serde(with = "byte_wrapper::HexArray::<32>")] + // If and when this type changes next, delete the `schemars(schema_with)` + // line and this comment. #[schemars(schema_with = "omicron_common::hex_schema::<32>")] N32([u8; 32]), } @@ -78,7 +82,9 @@ const ED25519_SIG_LEN: usize = 64; #[derive(Deserialize, Serialize, JsonSchema)] #[serde(transparent)] pub struct Ed25519Signature( - #[serde(with = "serde_human_bytes::hex_array")] + #[serde(with = "byte_wrapper::HexArray::")] + // If and when this type changes next, delete the `schemars(schema_with)` + // line and this comment. #[schemars(schema_with = "omicron_common::hex_schema::")] pub [u8; ED25519_SIG_LEN], ); diff --git a/sled-agent/types/versions/src/add_trust_quorum_status/trust_quorum.rs b/sled-agent/types/versions/src/add_trust_quorum_status/trust_quorum.rs index a884710dab0..1c91ee7df32 100644 --- a/sled-agent/types/versions/src/add_trust_quorum_status/trust_quorum.rs +++ b/sled-agent/types/versions/src/add_trust_quorum_status/trust_quorum.rs @@ -15,8 +15,10 @@ use serde::{Deserialize, Serialize}; pub struct TrustQuorumNetworkConfig { pub generation: u64, /// A serialized blob of configuration data (base64 encoded). + // If and when this type changes next, delete the `schemars(with)` line + // and this comment. #[schemars(with = "String")] - #[serde(with = "serde_human_bytes::base64_vec")] + #[serde(with = "byte_wrapper::Base64Vec")] pub blob: Vec, } diff --git a/trust-quorum/types/versions/Cargo.toml b/trust-quorum/types/versions/Cargo.toml index 29747992890..da329cd1c28 100644 --- a/trust-quorum/types/versions/Cargo.toml +++ b/trust-quorum/types/versions/Cargo.toml @@ -8,6 +8,7 @@ license = "MPL-2.0" workspace = true [dependencies] +byte-wrapper.workspace = true daft.workspace = true derive_more.workspace = true gfss.workspace = true @@ -16,7 +17,6 @@ omicron-uuid-kinds.workspace = true omicron-workspace-hack.workspace = true rand = { workspace = true, features = ["os_rng"] } schemars.workspace = true -serde_human_bytes.workspace = true serde.workspace = true serde_with = { workspace = true, features = ["hex", "schemars_0_8"] } sled-hardware-types.workspace = true diff --git a/trust-quorum/types/versions/src/initial/crypto.rs b/trust-quorum/types/versions/src/initial/crypto.rs index 72b098ccfcc..120523071aa 100644 --- a/trust-quorum/types/versions/src/initial/crypto.rs +++ b/trust-quorum/types/versions/src/initial/crypto.rs @@ -26,7 +26,9 @@ use slog_error_chain::SlogInlineError; )] #[schemars(transparent)] pub struct Sha3_256Digest( - #[serde(with = "serde_human_bytes::hex_array")] + #[serde(with = "byte_wrapper::HexArray::<32>")] + // If and when this type changes next, delete the `schemars(schema_with)` + // line and this comment. #[schemars(schema_with = "hex_schema::<32>")] pub [u8; 32], ); @@ -57,7 +59,9 @@ impl std::fmt::Debug for Sha3_256Digest { )] #[schemars(transparent)] pub struct Salt( - #[serde(with = "serde_human_bytes::hex_array")] + #[serde(with = "byte_wrapper::HexArray::<32>")] + // If and when this type changes next, delete the `schemars(schema_with)` + // line and this comment. #[schemars(schema_with = "hex_schema::<32>")] pub [u8; 32], );