-
Couldn't load subscription status.
- Fork 59
TQ: Async Nodes and P2P connections #9258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
andrewjstone
wants to merge
14
commits into
main
Choose a base branch
from
tq-sprockets
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
bf313f0
TQ: Async Nodes and P2P connections
andrewjstone 7d20b2d
hakari
andrewjstone 78143bd
Fix up step method
andrewjstone 5a89a98
Use JoinSet and tokio::task::Id instead of FuturesUnordered and crate…
andrewjstone 2af7f29
logging cleanup
andrewjstone 56e2018
more review cleanup
andrewjstone 19453d3
sock writer shutdown works again
andrewjstone 5ac98d0
clippy
andrewjstone 7f9060b
Review comments
andrewjstone 9c17716
Use BiHashMap and TriHashMap for connections
andrewjstone dc1e778
No more graceful close from ConnMgr
andrewjstone 40906c6
no more test detritus
andrewjstone 79a6730
Move sans-io code into trust-quorum-protocol crate
andrewjstone aadc7ab
hakari
andrewjstone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| [package] | ||
| name = "trust-quorum-protocol" | ||
| version = "0.1.0" | ||
| edition = "2021" | ||
| license = "MPL-2.0" | ||
| description = "sans-io trust quorum protocol implementation" | ||
|
|
||
| [lints] | ||
| workspace = true | ||
|
|
||
| [dependencies] | ||
| bootstore.workspace = true | ||
| bytes.workspace = true | ||
| camino.workspace = true | ||
| chacha20poly1305.workspace = true | ||
| ciborium.workspace = true | ||
| daft.workspace = true | ||
| derive_more.workspace = true | ||
| gfss.workspace = true | ||
| hex.workspace = true | ||
| hkdf.workspace = true | ||
| iddqd.workspace = true | ||
| omicron-uuid-kinds.workspace = true | ||
| rand = { workspace = true, features = ["os_rng"] } | ||
| secrecy.workspace = true | ||
| serde.workspace = true | ||
| serde_with.workspace = true | ||
| sha3.workspace = true | ||
| sled-agent-types.workspace = true | ||
| slog.workspace = true | ||
| slog-error-chain.workspace = true | ||
| static_assertions.workspace = true | ||
| subtle.workspace = true | ||
| thiserror.workspace = true | ||
| uuid.workspace = true | ||
| zeroize.workspace = true | ||
| omicron-workspace-hack.workspace = true | ||
|
|
||
| [dev-dependencies] | ||
| assert_matches.workspace = true | ||
| attest-mock.workspace = true | ||
| dropshot.workspace = true | ||
| omicron-test-utils.workspace = true | ||
| proptest.workspace = true | ||
| serde_json.workspace = true | ||
| test-strategy.workspace = true | ||
| trust-quorum-test-utils.workspace = true | ||
|
|
||
| [features] | ||
| # Impl `PartialEq` and `Eq` for types implementing `subtle::ConstantTimeEq` when | ||
| # this feature is enabled. | ||
| # | ||
| # This is of unknown risk. The rust compiler may obviate the security of using | ||
| # subtle when we do this. On the other hand its very useful for testing and | ||
| # debugging outside of production. | ||
| danger_partial_eq_ct_wrapper = ["gfss/danger_partial_eq_ct_wrapper"] | ||
| testing = [] |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| // This Source Code Form is subject to the terms of the Mozilla Public | ||
| // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| // file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
|
||
| //! Implementation of the oxide rack trust quorum protocol | ||
| //! | ||
| //! This protocol is written as a | ||
| //! [no-IO](https://sans-io.readthedocs.io/how-to-sans-io.html) implementation. | ||
| //! All persistent state and all networking is managed outside of this | ||
| //! implementation. | ||
|
|
||
| use crypto::Sha3_256Digest; | ||
| use daft::Diffable; | ||
| use derive_more::Display; | ||
| use gfss::shamir::Share; | ||
| use serde::{Deserialize, Serialize}; | ||
| pub use sled_agent_types::sled::BaseboardId; | ||
| use slog::{Logger, error, warn}; | ||
|
|
||
| mod alarm; | ||
| mod compute_key_share; | ||
| mod configuration; | ||
| mod coordinator_state; | ||
| pub(crate) mod crypto; | ||
| mod messages; | ||
| mod node; | ||
| mod node_ctx; | ||
| mod persistent_state; | ||
| #[allow(unused)] | ||
| mod rack_secret_loader; | ||
| mod validators; | ||
|
|
||
| pub use configuration::Configuration; | ||
| pub use coordinator_state::{ | ||
| CoordinatingMsg, CoordinatorOperation, CoordinatorState, | ||
| CoordinatorStateDiff, | ||
| }; | ||
| pub use rack_secret_loader::{LoadRackSecretError, RackSecretLoaderDiff}; | ||
| pub use validators::{ | ||
| ValidatedLrtqUpgradeMsgDiff, ValidatedReconfigureMsgDiff, | ||
| }; | ||
|
|
||
| pub use alarm::Alarm; | ||
| pub use crypto::RackSecret; | ||
| pub use messages::*; | ||
| pub use node::{Node, NodeDiff}; | ||
| // public only for docs. | ||
| pub use node_ctx::NodeHandlerCtx; | ||
| pub use node_ctx::{NodeCallerCtx, NodeCommonCtx, NodeCtx, NodeCtxDiff}; | ||
| pub use persistent_state::{ | ||
| ExpungedMetadata, PersistentState, PersistentStateSummary, | ||
| }; | ||
|
|
||
| #[derive( | ||
| Debug, | ||
| Clone, | ||
| Copy, | ||
| PartialEq, | ||
| Eq, | ||
| PartialOrd, | ||
| Ord, | ||
| Hash, | ||
| Serialize, | ||
| Deserialize, | ||
| Display, | ||
| Diffable, | ||
| )] | ||
| #[daft(leaf)] | ||
| pub struct Epoch(pub u64); | ||
|
|
||
| impl Epoch { | ||
| pub fn next(&self) -> Epoch { | ||
| Epoch(self.0.checked_add(1).expect("fewer than 2^64 epochs")) | ||
| } | ||
| } | ||
|
|
||
| /// The number of shares required to reconstruct the rack secret | ||
| /// | ||
| /// Typically referred to as `k` in the docs | ||
| #[derive( | ||
| Debug, | ||
| Clone, | ||
| Copy, | ||
| PartialEq, | ||
| Eq, | ||
| PartialOrd, | ||
| Ord, | ||
| Serialize, | ||
| Deserialize, | ||
| Display, | ||
| Diffable, | ||
| )] | ||
| #[daft(leaf)] | ||
| pub struct Threshold(pub u8); | ||
|
|
||
| /// A container to make messages between trust quorum nodes routable | ||
| #[derive(Debug, Clone, Serialize, Deserialize, Diffable)] | ||
| #[cfg_attr(feature = "danger_partial_eq_ct_wrapper", derive(PartialEq, Eq))] | ||
| #[daft(leaf)] | ||
| pub struct Envelope { | ||
| pub to: BaseboardId, | ||
| pub from: BaseboardId, | ||
| pub msg: PeerMsg, | ||
| } | ||
|
|
||
| #[cfg(feature = "testing")] | ||
| impl Envelope { | ||
| pub fn equal_except_for_crypto_data(&self, other: &Self) -> bool { | ||
| self.to == other.to | ||
| && self.from == other.from | ||
| && self.msg.equal_except_for_crypto_data(&other.msg) | ||
| } | ||
| } | ||
|
|
||
| /// Check if a received share is valid for a given configuration | ||
| /// | ||
| /// Return true if valid, false otherwise. | ||
| pub fn validate_share( | ||
| log: &Logger, | ||
| config: &Configuration, | ||
| from: &BaseboardId, | ||
| epoch: Epoch, | ||
| share: &Share, | ||
| ) -> bool { | ||
| // Are we trying to retrieve shares for `epoch`? | ||
| if epoch != config.epoch { | ||
| warn!( | ||
| log, | ||
| "Received Share from node with wrong epoch"; | ||
| "received_epoch" => %epoch, | ||
| "from" => %from | ||
| ); | ||
| return false; | ||
| } | ||
|
|
||
| // Is the sender a member of the configuration `epoch`? | ||
| // Was the sender a member of the configuration at `old_epoch`? | ||
| let Some(expected_digest) = config.members.get(&from) else { | ||
| warn!( | ||
| log, | ||
| "Received Share from unexpected node"; | ||
| "epoch" => %epoch, | ||
| "from" => %from | ||
| ); | ||
| return false; | ||
| }; | ||
|
|
||
| // Does the share hash match what we expect? | ||
| let mut digest = Sha3_256Digest::default(); | ||
| share.digest::<sha3::Sha3_256>(&mut digest.0); | ||
| if digest != *expected_digest { | ||
| error!( | ||
| log, | ||
| "Received share with invalid digest"; | ||
| "epoch" => %epoch, | ||
| "from" => %from | ||
| ); | ||
| return false; | ||
| } | ||
|
|
||
| true | ||
| } |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just pulls in a couple of helpers.