-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify block context for reads (#1391)
Right now, the `ReadResponse` sends back a `Vec<Option<BlockContext>>`, i.e. an `Option<BlockContext>` for each block. The `BlockContext` in turn contains ```rust pub struct BlockContext { pub hash: u64, pub encryption_context: Option<EncryptionContext>, } ``` If `encryption_context` is populated, then sending `hash` to the Upstairs is unnecessary: we are using authenticated encryption, so we know whether the block data + context is valid based on whether it decrypted successfully. This PR removes `hash` from the `ReadResponse` message in favor of a new `enum`: ```rust #[derive(Debug, PartialEq, Copy, Clone, Serialize, Deserialize)] pub enum ReadBlockContext { Empty, Encrypted { ctx: EncryptionContext }, Unencrypted { hash: u64 }, } ``` This does not change the on-disk format or write message format, which both continue to use hashes: - When **sending** data to the Downstairs, the hash (in `BlockContext`) lets us detect corruption in transit. We can't use the encryption context here, because the Downstairs isn't allowed to have encryption keys - When recovering from a bad write, `on_disk_hash` is used to figure out which context slot is valid. `on_disk_hash` is never sent over the network¹ This PR is a step towards [RFD 490 § Metadata reduction](https://rfd.shared.oxide.computer/rfd/490#_metadata_reduction), which proposes to **not** store block hashes for encrypted data on disk. If in the future we don't store block hashes for encrypted data, we would not be able to send them over the network; this PR removes that future hurdle. However, the PR stands alone as a small optimization (39 → 32 bytes per block) that simplifies program behavior (no need to think about what happens if encryption fails but the hash matches, or vice versa). ¹ `on_disk_hash` is also _technically_ superfluous if we already have `hash` (see #1161), but this PR doesn't change it
- Loading branch information
Showing
14 changed files
with
286 additions
and
261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.